aboutsummaryrefslogtreecommitdiff
path: root/bbot/machine-manifest.cxx
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2017-04-20 18:35:48 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2017-04-20 21:38:07 +0300
commit250d64faada1a9d0212be07cab6d54a112689b1b (patch)
tree395a4ea3c8a71d2ad853955ec98391a2783ad8ee /bbot/machine-manifest.cxx
parent22e086d8ea6ac2a4978eada0fa9ffb3a13a96ce3 (diff)
Add support for machine manifest options value
Diffstat (limited to 'bbot/machine-manifest.cxx')
-rw-r--r--bbot/machine-manifest.cxx44
1 files changed, 42 insertions, 2 deletions
diff --git a/bbot/machine-manifest.cxx b/bbot/machine-manifest.cxx
index 5cef054..2edf3dc 100644
--- a/bbot/machine-manifest.cxx
+++ b/bbot/machine-manifest.cxx
@@ -4,6 +4,7 @@
#include <bbot/machine-manifest>
+#include <butl/string-parser>
#include <butl/manifest-parser>
#include <butl/manifest-serializer>
@@ -62,9 +63,9 @@ namespace bbot
throw parsing (p.name (), nv.name_line, nv.name_column, d);
};
- auto bad_value = [&p, &nv] (const string& d)
+ auto bad_value = [&p, &nv] (const string& d, size_t offset = 0)
{
- throw parsing (p.name (), nv.value_line, nv.value_column, d);
+ throw parsing (p.name (), nv.value_line, nv.value_column + offset, d);
};
// Make sure this is the start and we support the version.
@@ -133,6 +134,28 @@ namespace bbot
mac = move (v);
}
+ else if (n == "options")
+ {
+ if (options)
+ bad_name ("machine options redefinition");
+
+ strings op;
+
+ try
+ {
+ op = string_parser::parse_quoted (v, false);
+ }
+ catch (const invalid_string& e)
+ {
+ bad_value (string ("invalid machine options: ") + e.what (),
+ e.position);
+ }
+
+ if (op.empty ())
+ bad_value ("empty machine options");
+
+ options = move (op);
+ }
else if (!iu)
bad_name ("unknown name '" + n + "' in machine manifest");
}
@@ -169,6 +192,23 @@ namespace bbot
if (mac)
s.next ("mac", *mac);
+ // Recompose options string as a space-separated option list,
+ //
+ if (options)
+ {
+ string v;
+ for (auto b (options->cbegin ()), i (b), e (options->cend ()); i != e;
+ ++i)
+ {
+ if (i != b)
+ v += ' ';
+
+ v += *i;
+ }
+
+ s.next ("options", v);
+ }
+
s.next ("", ""); // End of manifest.
}