From fbb1fc469da566dd21be47a7998dfad11d3085b7 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 23 Nov 2022 13:42:52 +0200 Subject: Take into account ad hoc recipes in rule::sub_match() (fixed GH issue #227) --- libbuild2/rule.cxx | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'libbuild2/rule.cxx') diff --git a/libbuild2/rule.cxx b/libbuild2/rule.cxx index e5d5248..c5366a6 100644 --- a/libbuild2/rule.cxx +++ b/libbuild2/rule.cxx @@ -30,10 +30,25 @@ namespace build2 return nullptr; } + const rule_match* + match_adhoc_recipe (action, target&, match_extra&); // algorithm.cxx + bool rule:: sub_match (const string& n, operation_id o, action a, target& t, match_extra& me) const { + // First check for an ad hoc recipe (see match_rule() for details). + // + if (!t.adhoc_recipes.empty ()) + { + // Use scratch match_extra since if there is no recipe, then we don't + // want to keep any changes and if there is, then we want it discarded. + // + match_extra s; + if (match_adhoc_recipe (action (a.meta_operation (), o), t, s) != nullptr) + return false; + } + const string& h (t.find_hint (o)); return name_rule_map::sub (h, n) && match (a, t, h, me); } @@ -56,6 +71,13 @@ namespace build2 sub_match (const string& n, operation_id o, action a, target& t) const { + if (!t.adhoc_recipes.empty ()) + { + match_extra s; + if (match_adhoc_recipe (action (a.meta_operation (), o), t, s) != nullptr) + return false; + } + return name_rule_map::sub (t.find_hint (o), n) && match (a, t); } -- cgit v1.1