aboutsummaryrefslogtreecommitdiff
path: root/build/config/utility.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2015-08-24 09:51:15 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2015-08-24 14:52:43 +0200
commit68f96f9213e849d0d7c4cedf3edeaec99743ee27 (patch)
tree271913d74c906971cac555319f5e14d0c66e0c16 /build/config/utility.cxx
parent0d5234f4aefd3cc5b5948cc1b9dd009e50046f5e (diff)
New variable architecture
Diffstat (limited to 'build/config/utility.cxx')
-rw-r--r--build/config/utility.cxx45
1 files changed, 12 insertions, 33 deletions
diff --git a/build/config/utility.cxx b/build/config/utility.cxx
index e2afc80..ce723fe 100644
--- a/build/config/utility.cxx
+++ b/build/config/utility.cxx
@@ -10,32 +10,14 @@ namespace build
{
namespace config
{
- // The same as the template except it is a bit more efficient
- // when it comes to not creating the default value string
- // unnecessarily.
- //
- pair<const string&, bool>
- required (scope& root, const char* name, const char* def_value)
+ const value&
+ optional (scope& root, const variable& var)
{
- string r;
- const variable& var (variable_pool.find (name));
+ auto l (root[var]);
- if (auto v = root[var])
- {
- const string& s (v.as<const string&> ());
-
- if (!v.belongs (*global_scope)) // A value from (some) config.build.
- return pair<const string&, bool> (s, false);
-
- r = s;
- }
- else
- r = def_value;
-
- auto v (root.assign (var));
- v = move (r);
-
- return pair<const string&, bool> (v.as<const string&> (), true);
+ return l.defined ()
+ ? l.belongs (*global_scope) ? (root.assign (var) = *l) : *l
+ : root.assign (var); // NULL
}
bool
@@ -54,17 +36,14 @@ namespace build
}
void
- append_options (cstrings& args, const list_value& lv, const char* var)
+ append_options (cstrings& args, const const_strings_value& sv)
{
- for (const name& n: lv)
+ if (!sv.empty ())
{
- 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;
+ args.reserve (args.size () + sv.size ());
+
+ for (const string& s: sv)
+ args.push_back (s.c_str ());
}
}
}