aboutsummaryrefslogtreecommitdiff
path: root/build/config/utility.cxx
diff options
context:
space:
mode:
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)
{