aboutsummaryrefslogtreecommitdiff
path: root/libbbot
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2018-11-20 15:38:30 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2018-11-27 23:12:33 +0300
commit48d1a2bd4d8e3cc2407cc7b696810a0f4910814a (patch)
tree3a5cef2316a786355b0a8828da9dcae5fb1e05b3 /libbbot
parent05912fbf27846af1f4ca1b824cc39815179d430e (diff)
Add support for configuration classes in buildtab
Diffstat (limited to 'libbbot')
-rw-r--r--libbbot/build-config.cxx34
-rw-r--r--libbbot/build-config.hxx7
2 files changed, 37 insertions, 4 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)
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<std::string> vars; // Note: quoting is preserved.
+ std::vector<std::string> classes;
+ std::vector<std::string> vars; // Note: quoting is preserved.
// Warning-detecting regular expressions. Note that quoting is preserved.
//