aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/rule.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2022-11-23 13:42:52 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2022-11-23 13:42:52 +0200
commitfbb1fc469da566dd21be47a7998dfad11d3085b7 (patch)
treea648f79125af89c86c9d9efa411624c816904baf /libbuild2/rule.cxx
parentc6b1d1dd870b3370d0a09fb4600e3a6b03326f35 (diff)
Take into account ad hoc recipes in rule::sub_match() (fixed GH issue #227)
Diffstat (limited to 'libbuild2/rule.cxx')
-rw-r--r--libbuild2/rule.cxx22
1 files changed, 22 insertions, 0 deletions
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);
}