From 48d1a2bd4d8e3cc2407cc7b696810a0f4910814a Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Tue, 20 Nov 2018 15:38:30 +0300 Subject: Add support for configuration classes in buildtab --- libbbot/build-config.cxx | 34 +++++++++++++++++++++++++++++++++- libbbot/build-config.hxx | 7 ++++--- 2 files changed, 37 insertions(+), 4 deletions(-) (limited to 'libbbot') diff --git a/libbbot/build-config.cxx b/libbbot/build-config.cxx index 23935e3..de9a71d 100644 --- a/libbbot/build-config.cxx +++ b/libbbot/build-config.cxx @@ -12,6 +12,9 @@ #include #include #include +#include + +#include // build_class_term::validate_name() #include // task_manifest::check_config() @@ -53,7 +56,7 @@ namespace bbot build_config config; config.machine_pattern = move (tl[i++].value); - // Configuration name field is a required one. + // Configuration name, target and classes fields are the required ones. // if (i == n) bad_line ("no configuration name found"); @@ -80,6 +83,35 @@ namespace bbot bad_line (e.what ()); } + if (++i == n) + bad_line ("no classes found"); + + // Parse a potentially quoted class list. + // + try + { + // We don't expect the class names be quotes as they cannot contain + // spaces. + // + using namespace string_parser; + config.classes = parse_quoted (unquote (tl[i].value), + false /* unquote */); + + // Validate the class names. + // + for (const string& c: config.classes) + { + if (c == "none") + throw invalid_argument ("class 'none' is reserved"); + + bpkg::build_class_term::validate_name (c); + } + } + catch (const invalid_argument& e) + { + bad_line (e.what ()); + } + try { for (++i; i < n; ++i) diff --git a/libbbot/build-config.hxx b/libbbot/build-config.hxx index 7ff5eba..3f1c0cc 100644 --- a/libbbot/build-config.hxx +++ b/libbbot/build-config.hxx @@ -23,10 +23,11 @@ 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. + std::vector classes; + std::vector vars; // Note: quoting is preserved. // Warning-detecting regular expressions. Note that quoting is preserved. // -- cgit v1.1