From 2a9d673f298b623db061ee85d397563d644c8268 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sat, 29 Aug 2015 08:14:27 +0200 Subject: New configure meta-operation implementation Now we search and match (but do not execute) a rule for every operation supported by the project. --- build/config/module.cxx | 8 +++++++- build/config/operation.cxx | 45 ++++++++++++++++++++++++++++++++------------- 2 files changed, 39 insertions(+), 14 deletions(-) (limited to 'build/config') diff --git a/build/config/module.cxx b/build/config/module.cxx index fbb51af..5ecf2d3 100644 --- a/build/config/module.cxx +++ b/build/config/module.cxx @@ -6,8 +6,9 @@ #include -#include #include +#include +#include #include #include @@ -49,6 +50,11 @@ namespace build r.meta_operations.insert (configure_id, configure); r.meta_operations.insert (disfigure_id, disfigure); + // Register alias and fallback rule for the configure meta-operation. + // + r.rules.insert (configure_id, 0, "alias", alias_rule::instance); + r.rules.insert (configure_id, 0, "", fallback_rule::instance); + // Load config.build if one exists. // path f (out_root / config_file); diff --git a/build/config/operation.cxx b/build/config/operation.cxx index 80b92dc..b1c6239 100644 --- a/build/config/operation.cxx +++ b/build/config/operation.cxx @@ -12,6 +12,7 @@ #include #include #include +#include #include using namespace std; @@ -187,26 +188,44 @@ namespace build } static void - configure_search (scope& root, - const target_key&, - const location&, - action_targets& ts) + configure_match (action, action_targets&) { - tracer trace ("configure_search"); - level5 ([&]{trace << "collecting " << root.path ();}); - ts.push_back (&root); + // Don't match anything -- see execute (). } static void - configure_match (action, action_targets&) {} - - static void configure_execute (action a, const action_targets& ts, bool) { + // Match rules to configure every operation supported by each + // project. Note that we are not calling operation_pre/post() + // callbacks here since the meta operation is configure and we + // know what we are doing. + // for (void* v: ts) { - scope& root (*static_cast (v)); - configure_project (a, root); + target& t (*static_cast (v)); + scope* rs (t.base_scope ().root_scope ()); + + if (rs == nullptr) + fail << "out of project target " << t; + + for (operations::size_type id (default_id + 1); // Skip default_id + id < rs->operations.size (); + ++id) + { + const operation_info* oi (rs->operations[id]); + if (oi == nullptr) + continue; + + current_inner_oif = oi; + current_outer_oif = nullptr; + current_mode = oi->mode; + dependency_count = 0; + + match (action (configure_id, id), t); + } + + configure_project (a, *rs); } } @@ -218,7 +237,7 @@ namespace build nullptr, // meta-operation pre &configure_operation_pre, &load, // normal load - &configure_search, + &search, // normal search &configure_match, &configure_execute, nullptr, // operation post -- cgit v1.1