aboutsummaryrefslogtreecommitdiff
path: root/build/config/utility.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2015-04-24 12:29:20 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2015-04-24 12:29:20 +0200
commit2a0f9e035f673f1ee387924501a31990de37f18d (patch)
treeb8e55ab74bc88b788e99d8649219b931b80432d5 /build/config/utility.cxx
parent4c44c914d898af53152addad5530504548175e85 (diff)
Implement lib/liba/libso{} target group, shared/static library build
Diffstat (limited to 'build/config/utility.cxx')
-rw-r--r--build/config/utility.cxx41
1 files changed, 41 insertions, 0 deletions
diff --git a/build/config/utility.cxx b/build/config/utility.cxx
new file mode 100644
index 0000000..8b26239
--- /dev/null
+++ b/build/config/utility.cxx
@@ -0,0 +1,41 @@
+// file : build/config/utility.cxx -*- C++ -*-
+// copyright : Copyright (c) 2014-2015 Code Synthesis Tools CC
+// license : MIT; see accompanying LICENSE file
+
+#include <build/config/utility>
+
+using namespace std;
+
+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)
+ {
+ string r;
+ const variable& var (variable_pool.find (name));
+
+ 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);
+ }
+ }
+}