From e815af118562c68794efbd310c887acd8eae800c Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 24 Jun 2015 13:53:28 +0200 Subject: First take on the cli module plus necessary infrastructure --- build/config/utility | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'build/config/utility') diff --git a/build/config/utility b/build/config/utility index 83fcd75..3da990f 100644 --- a/build/config/utility +++ b/build/config/utility @@ -5,9 +5,13 @@ #ifndef BUILD_CONFIG_UTILITY #define BUILD_CONFIG_UTILITY +#include #include #include // pair +#include +#include + namespace build { class scope; @@ -37,6 +41,26 @@ namespace build template const T* optional (scope& root, const char* name); + + // Add all the values from a variable to the C-string list. T is + // either target or scope. + // + template + void + append_options (std::vector& args, T& s, const char* var) + { + if (auto val = s[var]) + { + for (const name& n: val.template as ()) + { + if (!n.type.empty () || !n.dir.empty ()) + fail << "expected option instead of " << n << + info << "in variable " << var; + + args.push_back (n.value.c_str ()); + } + } + } } } -- cgit v1.1