From fd689eb883655dcb29e505b041cd02fac01f0bac Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 27 Aug 2015 15:11:40 +0200 Subject: Dist module/meta-operation initial implementation --- build/config/utility.cxx | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'build/config/utility.cxx') 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 +#include + 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 (*l)); + + if (v && !v.empty ()) + { + dir_path& d (as (v)); + + if (d.relative ()) + { + d = work / d; + d.normalize (); + } + } + + return root.assign (var) = v; + } + bool specified (scope& r, const string& ns) { -- cgit v1.1