diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2015-08-27 15:11:40 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2015-08-27 15:11:40 +0200 |
commit | fd689eb883655dcb29e505b041cd02fac01f0bac (patch) | |
tree | 0d85ec32d95a1c96eaa7eff28734b900c44dd3ca /build/config | |
parent | 7f2d06258d57e39940e8fa959336da0ea66fe37f (diff) |
Dist module/meta-operation initial implementation
Diffstat (limited to 'build/config')
-rw-r--r-- | build/config/operation.cxx | 34 | ||||
-rw-r--r-- | build/config/utility | 19 | ||||
-rw-r--r-- | build/config/utility.cxx | 33 |
3 files changed, 71 insertions, 15 deletions
diff --git a/build/config/operation.cxx b/build/config/operation.cxx index 913ae29..80b92dc 100644 --- a/build/config/operation.cxx +++ b/build/config/operation.cxx @@ -187,17 +187,26 @@ namespace build } static void - configure_execute (action a, const action_targets& ts) + configure_search (scope& root, + const target_key&, + const location&, + action_targets& ts) { - for (void* v: ts) - { - target& t (*static_cast<target*> (v)); - scope* rs (t.base_scope ().root_scope ()); + tracer trace ("configure_search"); + level5 ([&]{trace << "collecting " << root.path ();}); + ts.push_back (&root); + } - if (rs == nullptr) - fail << "out of project target " << t; + static void + configure_match (action, action_targets&) {} - configure_project (a, *rs); + static void + configure_execute (action a, const action_targets& ts, bool) + { + for (void* v: ts) + { + scope& root (*static_cast<scope*> (v)); + configure_project (a, root); } } @@ -209,8 +218,8 @@ namespace build nullptr, // meta-operation pre &configure_operation_pre, &load, // normal load - &search, // normal search - &match, // normal match + &configure_search, + &configure_match, &configure_execute, nullptr, // operation post nullptr // meta-operation post @@ -355,7 +364,7 @@ namespace build } static void - disfigure_execute (action a, const action_targets& ts) + disfigure_execute (action a, const action_targets& ts, bool quiet) { tracer trace ("disfigure_execute"); @@ -372,7 +381,8 @@ namespace build targets.insert ( dir::static_type, root.path (), "", nullptr, trace).first); - info << diag_done (a, t); + if (!quiet) + info << diag_done (a, t); } } } diff --git a/build/config/utility b/build/config/utility index 82f71fe..406c271 100644 --- a/build/config/utility +++ b/build/config/utility @@ -49,12 +49,25 @@ namespace build // Return the value, which can be NULL. // const value& - optional (scope& root, const variable& var); + optional (scope& root, const variable&); inline const value& - optional (scope& root, const std::string& name) + optional (scope& root, const std::string& var) { - return optional (root, variable_pool.find (name)); + return optional (root, variable_pool.find (var)); + } + + // As above but assumes the value is dir_path and makes it + // absolute if the value specified on the command line is + // relative. + // + const value& + optional_absolute (scope& root, const variable&); + + inline const value& + optional_absolute (scope& root, const std::string& var) + { + return optional_absolute (root, variable_pool.find (var)); } // Check whether there are any variables specified from the 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) { |