From 934f2a9a90c5cad3cdc8a66b50c17827a3ddbcee Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sat, 20 Jan 2018 13:46:11 +0200 Subject: Get rid of action rule override semantics Instead we now have two more or less separate match states for outer and inner parts of an action. --- build2/bin/init.cxx | 25 ++++++++++++++++++------- build2/bin/rule.cxx | 24 ++++++++---------------- build2/bin/rule.hxx | 9 ++++++--- build2/bin/target.cxx | 4 ++-- build2/bin/target.hxx | 2 +- 5 files changed, 35 insertions(+), 29 deletions(-) (limited to 'build2/bin') diff --git a/build2/bin/init.cxx b/build2/bin/init.cxx index d9f3c0e..565936f 100644 --- a/build2/bin/init.cxx +++ b/build2/bin/init.cxx @@ -11,6 +11,10 @@ #include #include + +#include + +#include #include #include @@ -456,17 +460,24 @@ namespace build2 r.insert (perform_update_id, "bin.libu", fail_); r.insert (perform_clean_id, "bin.libu", fail_); - r.insert (perform_update_id, "bin.lib", lib_); - r.insert (perform_clean_id, "bin.lib", lib_); - - // Configure members. + // Similar to alias. // - r.insert (configure_update_id, "bin.lib", lib_); + r.insert (perform_id, 0, "bin.lib", lib_); + r.insert (configure_id, 0, "bin.lib", lib_); + // Treat as a see through group for install and test. + // if (install_loaded) { - r.insert (perform_install_id, "bin.lib", lib_); - r.insert (perform_uninstall_id, "bin.lib", lib_); + auto& gr (install::group_rule::instance); + + r.insert (perform_install_id, "bin.lib", gr); + r.insert (perform_uninstall_id, "bin.lib", gr); + } + + if (const test::module* m = rs.modules.lookup ("test")) + { + r.insert (perform_test_id, "bin.lib", m->group_rule ()); } } diff --git a/build2/bin/rule.cxx b/build2/bin/rule.cxx index bb9036b..79270c3 100644 --- a/build2/bin/rule.cxx +++ b/build2/bin/rule.cxx @@ -19,7 +19,7 @@ namespace build2 { // fail_rule // - match_result fail_rule:: + bool fail_rule:: match (action a, target& t, const string&) const { const char* n (t.dynamic_type ().name); // Ignore derived type. @@ -37,8 +37,8 @@ namespace build2 // The whole logic is pretty much as if we had our two group members as // our prerequisites. // - match_result lib_rule:: - match (action act, target& xt, const string&) const + bool lib_rule:: + match (action, target& xt, const string&) const { lib& t (xt.as ()); @@ -57,35 +57,27 @@ namespace build2 t.a = a ? &search (t, t.dir, t.out, t.name) : nullptr; t.s = s ? &search (t, t.dir, t.out, t.name) : nullptr; - match_result mr (true); - - // If there is an outer operation, indicate that we match - // unconditionally so that we don't override ourselves. - // - if (act.outer_operation () != 0) - mr.recipe_action = action (act.meta_operation (), act.operation ()); - - return mr; + return true; } recipe lib_rule:: - apply (action act, target& xt) const + apply (action a, target& xt) const { lib& t (xt.as ()); const target* m[] = {t.a, t.s}; - match_members (act, t, m); + match_members (a, t, m); return &perform; } target_state lib_rule:: - perform (action act, const target& xt) + perform (action a, const target& xt) { const lib& t (xt.as ()); const target* m[] = {t.a, t.s}; - return execute_members (act, t, m); + return execute_members (a, t, m); } } } diff --git a/build2/bin/rule.hxx b/build2/bin/rule.hxx index b4835dc..6385830 100644 --- a/build2/bin/rule.hxx +++ b/build2/bin/rule.hxx @@ -14,26 +14,29 @@ namespace build2 { namespace bin { - // Fail rule for obj{}, bmi{}, and libu{}. + // "Fail rule" for obj{}, bmi{}, and libu{} that issues diagnostics if + // someone tries to build any of these groups directly. // class fail_rule: public rule { public: fail_rule () {} - virtual match_result + virtual bool match (action, target&, const string&) const override; virtual recipe apply (action, target&) const override; }; + // Pass-through to group members rule, similar to alias. + // class lib_rule: public rule { public: lib_rule () {} - virtual match_result + virtual bool match (action, target&, const string&) const override; virtual recipe diff --git a/build2/bin/target.cxx b/build2/bin/target.cxx index 533da43..2bcb8bc 100644 --- a/build2/bin/target.cxx +++ b/build2/bin/target.cxx @@ -281,7 +281,7 @@ namespace build2 // lib // group_view lib:: - group_members (action_type) const + group_members (action) const { static_assert (sizeof (lib_members) == sizeof (const target*) * 2, "member layout incompatible with array"); @@ -321,7 +321,7 @@ namespace build2 nullptr, nullptr, &target_search, - false + false // Note: not see-through ("alternatives" group). }; // libi diff --git a/build2/bin/target.hxx b/build2/bin/target.hxx index 790d1f0..329b4a9 100644 --- a/build2/bin/target.hxx +++ b/build2/bin/target.hxx @@ -226,7 +226,7 @@ namespace build2 using libx::libx; virtual group_view - group_members (action_type) const override; + group_members (action) const override; public: static const target_type static_type; -- cgit v1.1