From bbd0f3bb21442a2833916110cbe8e9a07e9f4c1f Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 31 Jul 2015 12:52:20 +0200 Subject: Essential install module functionality --- build/config/utility | 58 ++++++++++++++++++++++++++-------------------------- 1 file changed, 29 insertions(+), 29 deletions(-) (limited to 'build/config/utility') diff --git a/build/config/utility b/build/config/utility index 713ab01..ef3ceed 100644 --- a/build/config/utility +++ b/build/config/utility @@ -27,6 +27,13 @@ namespace build std::pair required (scope& root, const char* name, const T& default_value); + template + inline std::pair + required (scope& root, const std::string& name, const T& default_value) + { + return required (root, name.c_str (), default_value); + } + std::pair required (scope& root, const char* name, const char* default_value); @@ -48,45 +55,38 @@ namespace build return optional (root, name.c_str ()); } + // Check whether there are any variables specified from the + // config namespace. The idea is that we can check if there + // are any, say, config.install.* values. If there are none, + // then we can assume this functionality is not (yet) used + // and omit writing a whole bunch of NULL config.install.* + // values to config.build. We call it omitted/delayed + // configuration. + // + bool + specified (scope& root, const std::string& ns); + + // @@ Why are these here? + // + // Add all the values from a variable to the C-string list. T is // either target or scope. // template void - append_options (cstrings& args, T& s, const char* var) - { - if (auto val = s[var]) - { - for (const name& n: val.template as ()) - { - if (n.simple ()) - args.push_back (n.value.c_str ()); - else if (n.directory ()) - args.push_back (n.dir.string ().c_str ()); - else - fail << "expected option instead of " << n << - info << "in variable " << var; - } - } - } + append_options (cstrings& args, T& s, const char* var); + + // As above but from the list value directly. Variable name is for + // diagnostics. + // + void + append_options (cstrings& args, const list_value&, const char* var); // Check if a specified option is present. T is either target or scope. // template bool - find_option (const char* option, T& s, const char* var) - { - if (auto val = s[var]) - { - for (const name& n: val.template as ()) - { - if (n.simple () && n.value == option) - return true; - } - } - - return false; - } + find_option (const char* option, T& s, const char* var); } } -- cgit v1.1