From bf4822a17eed8bdaf9d337caf806c63c82b06a89 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Tue, 18 Jul 2017 13:36:04 +0300 Subject: Make buildtab target to be non-optional --- libbbot/build-config.cxx | 31 +++++++++---------------------- libbbot/build-config.hxx | 15 ++++++--------- libbbot/manifest.cxx | 9 +++++---- libbbot/manifest.hxx | 10 +++------- 4 files changed, 23 insertions(+), 42 deletions(-) (limited to 'libbbot') diff --git a/libbbot/build-config.cxx b/libbbot/build-config.cxx index f18c48a..855b093 100644 --- a/libbbot/build-config.cxx +++ b/libbbot/build-config.cxx @@ -63,39 +63,26 @@ namespace bbot // Make sure the name is unique. // for (const auto& c: r) + { if (c.name == config.name) bad_line ("duplicate configuration name"); + } - // If there is no target nor configuration variables then save the - // configuration and proceed with the next line. - // if (++i == n) + bad_line ("no target found"); + + try { - r.emplace_back (move (config)); - continue; + config.target = target_triplet (tl[i].value); } - - // If the third field doesn't start with '~' character and doesn't - // contain '=' character, then we will treat it as a target. - // - const string& v (tl[i].value); - if (v[0] != '~' && v.find ('=') == string::npos) + catch (const invalid_argument& e) { - try - { - config.target = target_triplet (v); - } - catch (const invalid_argument& e) - { - bad_line (e.what ()); - } - - ++i; + bad_line (e.what ()); } try { - for (; i < n; ++i) + for (++i; i < n; ++i) { string& v (tl[i].value); diff --git a/libbbot/build-config.hxx b/libbbot/build-config.hxx index 363b889..de78739 100644 --- a/libbbot/build-config.hxx +++ b/libbbot/build-config.hxx @@ -10,7 +10,6 @@ #include #include -#include #include #include @@ -24,14 +23,12 @@ namespace bbot // struct build_config { - std::string machine_pattern; // Machine name pattern. - std::string name; // Configuration name. + std::string machine_pattern; // Machine name pattern. + std::string name; // Configuration name. + butl::target_triplet target; + std::vector vars; // Note: quoting is preserved. - butl::optional target; - - std::vector vars; - - // Warning-detecting regular expressions. + // Warning-detecting regular expressions. Note that quoting is preserved. // std::vector warning_regexes; }; @@ -43,7 +40,7 @@ namespace bbot // // buildtab consists of lines in the following format: // - // [] [] [] + // [] [] // using butl::tab_parsing; diff --git a/libbbot/manifest.cxx b/libbbot/manifest.cxx index dae6e3e..8a2ebaa 100644 --- a/libbbot/manifest.cxx +++ b/libbbot/manifest.cxx @@ -517,7 +517,7 @@ namespace bbot } else if (n == "target") { - if (target) + if (!target.empty ()) bad_name ("task target redefinition"); try @@ -566,6 +566,9 @@ namespace bbot if (machine.empty ()) bad_value ("no task machine specified"); + + if (target.empty ()) + bad_value ("no task target specified"); } void task_manifest:: @@ -583,9 +586,7 @@ namespace bbot s.next ("trust", v); s.next ("machine", machine); - - if (target) - s.next ("target", target->string ()); + s.next ("target", target.string ()); // Serialize an optional value of the strings type as a space-separated // string list. diff --git a/libbbot/manifest.hxx b/libbbot/manifest.hxx index 36f2f5b..cd0ddfe 100644 --- a/libbbot/manifest.hxx +++ b/libbbot/manifest.hxx @@ -117,13 +117,9 @@ namespace bbot // strings trust; - // Build machine to use for building the package. - // - std::string machine; + std::string machine; // Build machine to use for building the package. - // Default for the machine if absent. - // - butl::optional target; + butl::target_triplet target; // Build system configuration variables (in addition to build environment // configuration variables). @@ -148,7 +144,7 @@ namespace bbot bpkg::repository_location rl, strings tr, std::string mn, - butl::optional tg, + butl::target_triplet tg, strings cf, strings wr) : name (std::move (nm)), -- cgit v1.1