From 250d64faada1a9d0212be07cab6d54a112689b1b Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Thu, 20 Apr 2017 18:35:48 +0300 Subject: Add support for machine manifest options value --- bbot/machine-manifest.cxx | 44 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 42 insertions(+), 2 deletions(-) (limited to 'bbot/machine-manifest.cxx') 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 +#include #include #include @@ -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. } -- cgit v1.1