aboutsummaryrefslogtreecommitdiff
path: root/build/config/utility.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2015-08-27 15:11:40 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2015-08-27 15:11:40 +0200
commitfd689eb883655dcb29e505b041cd02fac01f0bac (patch)
tree0d85ec32d95a1c96eaa7eff28734b900c44dd3ca /build/config/utility.cxx
parent7f2d06258d57e39940e8fa959336da0ea66fe37f (diff)
Dist module/meta-operation initial implementation
Diffstat (limited to 'build/config/utility.cxx')
-rw-r--r--build/config/utility.cxx33
1 files changed, 33 insertions, 0 deletions
diff --git a/build/config/utility.cxx b/build/config/utility.cxx
index ce723fe..c9d7c66 100644
--- a/build/config/utility.cxx
+++ b/build/config/utility.cxx
@@ -4,6 +4,8 @@
#include <build/config/utility>
+#include <build/context>
+
using namespace std;
namespace build
@@ -20,6 +22,37 @@ namespace build
: root.assign (var); // NULL
}
+ const value&
+ optional_absolute (scope& root, const variable& var)
+ {
+ auto l (root[var]);
+
+ if (!l.defined ())
+ return root.assign (var); // NULL
+
+ if (!l.belongs (*global_scope)) // Value from (some) root scope.
+ return *l;
+
+ // Make the command-line value absolute. This is necessary to avoid
+ // a warning issued by the config module about global/root scope
+ // value mismatch.
+ //
+ value& v (const_cast<value&> (*l));
+
+ if (v && !v.empty ())
+ {
+ dir_path& d (as<dir_path> (v));
+
+ if (d.relative ())
+ {
+ d = work / d;
+ d.normalize ();
+ }
+ }
+
+ return root.assign (var) = v;
+ }
+
bool
specified (scope& r, const string& ns)
{