diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2019-10-29 18:39:34 +0300 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2019-10-31 19:13:24 +0300 |
commit | b3633d94b0ec44575c7bbc0a741bf0e388beba72 (patch) | |
tree | 65433d99e6e95782ff0805ae18afcbaf2ba726e5 /libbbot | |
parent | 3b154abeabf1563c098a3296f4981ce86ec5b07f (diff) |
Add support for environment task manifest value
Diffstat (limited to 'libbbot')
-rw-r--r-- | libbbot/build-config.cxx | 25 | ||||
-rw-r--r-- | libbbot/build-config.hxx | 12 | ||||
-rw-r--r-- | libbbot/manifest.cxx | 13 | ||||
-rw-r--r-- | libbbot/manifest.hxx | 6 |
4 files changed, 48 insertions, 8 deletions
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 <iosfwd> #include <libbutl/path.mxx> +#include <libbutl/optional.mxx> #include <libbutl/tab-parser.mxx> #include <libbutl/target-triplet.mxx> @@ -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<std::string> environment; // Build environment name. std::vector<std::string> classes; - std::vector<std::string> args; // Note: quoting is preserved. + std::vector<std::string> 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: // - // <machine-pattern> <config> <target> <classes> [<config-arg>]* [<warning-regex>]* + // <machine-pattern> <config> <target>[/<environment>] <classes> [<config-arg>]* [<warning-regex>]* // 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<std::string> 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<std::string> 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)){} |