diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2018-11-20 15:38:30 +0300 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2018-11-27 23:12:33 +0300 |
commit | 48d1a2bd4d8e3cc2407cc7b696810a0f4910814a (patch) | |
tree | 3a5cef2316a786355b0a8828da9dcae5fb1e05b3 /libbbot/build-config.cxx | |
parent | 05912fbf27846af1f4ca1b824cc39815179d430e (diff) |
Add support for configuration classes in buildtab
Diffstat (limited to 'libbbot/build-config.cxx')
-rw-r--r-- | libbbot/build-config.cxx | 34 |
1 files changed, 33 insertions, 1 deletions
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 <libbutl/path.mxx> #include <libbutl/fdstream.mxx> #include <libbutl/tab-parser.mxx> +#include <libbutl/string-parser.mxx> + +#include <libbpkg/manifest.hxx> // build_class_term::validate_name() #include <libbbot/manifest.hxx> // 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) |