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 +++++- tests/buildtab/driver.cxx | 3 +++ tests/buildtab/testscript | 15 +++++++++++++++ tests/manifest/task.testscript | 3 ++- 7 files changed, 68 insertions(+), 9 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 #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)){} diff --git a/tests/buildtab/driver.cxx b/tests/buildtab/driver.cxx index c5fd24e..c7d7a1d 100644 --- a/tests/buildtab/driver.cxx +++ b/tests/buildtab/driver.cxx @@ -32,6 +32,9 @@ try { cout << c.machine_pattern << ' ' << c.name << ' ' << c.target; + if (c.environment) + cout << '/' << *c.environment; + string classes; for (const string& cls: c.classes) { diff --git a/tests/buildtab/testscript b/tests/buildtab/testscript index 0572335..e2bd2bc 100644 --- a/tests/buildtab/testscript +++ b/tests/buildtab/testscript @@ -19,6 +19,8 @@ linux_debian_9*-gcc_7.3 linux_debian_9-gcc_7.3 x86_64-linux-gnu "all default linux gcc gcc-7+:gcc-6+" linux_debian_9*-gcc_7.3 linux_debian_9-gcc_7.3-O3 x86_64-linux-gnu "all default linux gcc optimized gcc-7+" config.cc.coptions=-O3 linux_debian_9*-gcc_8.1 linux_debian_9-gcc_8.1 x86_64-linux-gnu "all default linux gcc gcc-8+:gcc-7+" + + windows_10*-clang_9.0_msvc_16.3 windows_10-clang_9.0_msvc_16.3_lld x86_64-microsoft-win32-msvc14.2/lld "all default windows clang" EOI windows*-vc_14* windows-vc_14-32 i686-microsoft-win32-msvc14.0 all windows*-vc_14* windows-vc_14-32-debug i686-microsoft-win32-msvc14.0 "" config.cc.coptions=/Z7 config.cc.loptions=/DEBUG ~"warning C4\d{3}: " @@ -26,6 +28,7 @@ linux_debian_9*-gcc_7.3 linux_debian_9-gcc_7.3 x86_64-linux-gnu "all default linux gcc gcc-7+:gcc-6+" linux_debian_9*-gcc_7.3 linux_debian_9-gcc_7.3-O3 x86_64-linux-gnu "all default linux gcc optimized gcc-7+:gcc-6+" config.cc.coptions=-O3 linux_debian_9*-gcc_8.1 linux_debian_9-gcc_8.1 x86_64-linux-gnu "all default linux gcc gcc-8+:gcc-7+" + windows_10*-clang_9.0_msvc_16.3 windows_10-clang_9.0_msvc_16.3_lld x86_64-microsoft-win32-msvc14.2/lld "all default windows clang" EOO : empty-lines @@ -81,6 +84,18 @@ EOE } + : environment + : + { + : empty + : + $* <>EOE == 1 + windows*-vc_14* windows-vc_14-32 i686-microsoft-win32-msvc14.0/ + EOI + cin:1:34: error: empty environment + EOE + } + : class : { diff --git a/tests/manifest/task.testscript b/tests/manifest/task.testscript index d1ea642..9852f91 100644 --- a/tests/manifest/task.testscript +++ b/tests/manifest/task.testscript @@ -20,11 +20,12 @@ test.options += -t 8:64:3C:73:60:F8:66:3A:A4 machine: windows_10-msvc_14 target: x86_64-microsoft-win32-msvc14.0 + environment: lld config: config.cc.coptions=/Z7 config.cc.loptions=/DEBUG warning-regex: '^warning: ' '^.+: warning: ' EOF - : no-config-no-regex + : no-config-regex-environment : $* <>EOF : 1 -- cgit v1.1