From b3633d94b0ec44575c7bbc0a741bf0e388beba72 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Tue, 29 Oct 2019 18:39:34 +0300 Subject: Add support for environment task manifest value --- libbbot/build-config.cxx | 25 +++++++++++++++++++++++-- libbbot/build-config.hxx | 12 +++++++----- libbbot/manifest.cxx | 13 +++++++++++++ libbbot/manifest.hxx | 6 +++++- 4 files changed, 48 insertions(+), 8 deletions(-) (limited to 'libbbot') diff --git a/libbbot/build-config.cxx b/libbbot/build-config.cxx index 1e8b8dc..65a64ab 100644 --- a/libbbot/build-config.cxx +++ b/libbbot/build-config.cxx @@ -68,7 +68,8 @@ namespace bbot // bool placeholder (config.machine_pattern == "-"); - // Configuration name, target and classes fields are the required ones. + // Configuration name, target[/environment] and classes fields are the + // required ones. // if (i == n) bad_line ("no configuration name found"); @@ -89,7 +90,27 @@ namespace bbot if (!placeholder) try { - config.target = target_triplet (tl[i].value); + const string& v (tl[i].value); + + // Extract the environment name, if present. + // + size_t p (v.find ('/')); + + if (p != string::npos) + { + string env (v, p + 1); + + if (env.empty ()) + bad_line ("empty environment"); + + config.environment = move (env); + } + + // Parse the target triplet. + // + config.target = target_triplet (p != string::npos + ? string (v, 0, p) + : v); } catch (const invalid_argument& e) { diff --git a/libbbot/build-config.hxx b/libbbot/build-config.hxx index 5c9296d..a7cc6a2 100644 --- a/libbbot/build-config.hxx +++ b/libbbot/build-config.hxx @@ -11,6 +11,7 @@ #include #include +#include #include #include @@ -24,11 +25,12 @@ namespace bbot // struct build_config { - std::string machine_pattern; // Machine name pattern. - std::string name; // Configuration name. - butl::target_triplet target; + std::string machine_pattern; // Machine name pattern. + std::string name; // Configuration name. + butl::target_triplet target; // Build target. + butl::optional environment; // Build environment name. std::vector classes; - std::vector args; // Note: quoting is preserved. + std::vector args; // Note: quoting is preserved. // Warning-detecting regular expressions. Note that quoting is preserved. // @@ -52,7 +54,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 a815f39..aa9d508 100644 --- a/libbbot/manifest.cxx +++ b/libbbot/manifest.cxx @@ -546,6 +546,16 @@ namespace bbot bad_value (string ("invalid task target: ") + e.what ()); } } + else if (n == "environment") + { + if (environment) + bad_name ("task environment redefinition"); + + if (v.empty ()) + bad_value ("empty task environment"); + + environment = move (v); + } else if (n == "config") { if (!config.empty ()) @@ -634,6 +644,9 @@ namespace bbot s.next ("machine", machine); s.next ("target", target.string ()); + if (environment) + s.next ("environment", *environment); + // 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 46cd6c4..73d8c9a 100644 --- a/libbbot/manifest.hxx +++ b/libbbot/manifest.hxx @@ -120,7 +120,9 @@ namespace bbot std::string machine; // Build machine to use for building the package. - butl::target_triplet target; + butl::target_triplet target; // Build target. + + butl::optional environment; // Build environment name. // Build system configuration variables (in addition to build environment // configuration variables). @@ -146,6 +148,7 @@ namespace bbot strings tr, std::string mn, butl::target_triplet tg, + butl::optional en, strings cf, strings wr) : name (std::move (nm)), @@ -154,6 +157,7 @@ namespace bbot trust (tr), machine (std::move (mn)), target (std::move (tg)), + environment (std::move (en)), config (std::move (cf)), warning_regex (std::move (wr)){} -- cgit v1.1