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/rule.hxx | 44 ++++++-------------------------------------- 1 file changed, 6 insertions(+), 38 deletions(-) (limited to 'build2/rule.hxx') diff --git a/build2/rule.hxx b/build2/rule.hxx index f6e23f6..8e43ca6 100644 --- a/build2/rule.hxx +++ b/build2/rule.hxx @@ -13,48 +13,16 @@ namespace build2 { - class match_result - { - public: - bool result; - - // If set, then this is a recipe's action. It must override the original - // action. Normally it is "unconditional inner operation". Only - // noop_recipe can be overridden. - // - // It is passed to rule::apply() so that prerequisites are matched for - // this action. It is also passed to target::recipe() so that if someone - // is matching this target for this action, we won't end-up re-matching - // it. However, the recipe itself is executed with the original action - // so that it can adjust its logic, if necessary. - // - action recipe_action = action (); - - explicit - operator bool () const {return result;} - - // Note that the from-bool constructor is intentionally implicit so that - // we can return true/false from match(). - // - match_result (bool r): result (r) {} - match_result (bool r, action a): result (r), recipe_action (a) {} - }; - // Once a rule is registered (for a scope), it is treated as immutable. If // you need to modify some state (e.g., counters or some such), then make // sure it is MT-safe. // - // Note that match() may not be followed by apply() or be called several - // times before the following apply() (see resolve_group_members()) which - // means that it should be idempotent. The target_data object in the call - // to match() may not be the same as target. - // - // match() can also be called by another rules (see cc/install). + // Note: match() is only called once but may not be followed by apply(). // class rule { public: - virtual match_result + virtual bool match (action, target&, const string& hint) const = 0; virtual recipe @@ -68,7 +36,7 @@ namespace build2 public: file_rule () {} - virtual match_result + virtual bool match (action, target&, const string&) const override; virtual recipe @@ -82,7 +50,7 @@ namespace build2 public: alias_rule () {} - virtual match_result + virtual bool match (action, target&, const string&) const override; virtual recipe @@ -96,7 +64,7 @@ namespace build2 public: fsdir_rule () {} - virtual match_result + virtual bool match (action, target&, const string&) const override; virtual recipe @@ -124,7 +92,7 @@ namespace build2 public: fallback_rule () {} - virtual match_result + virtual bool match (action, target&, const string&) const override { return true; -- cgit v1.1