From 9ec2bdd87659438b4aa021a10c4a4977ef77118e Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 5 Jun 2020 06:36:30 +0200 Subject: Add ability to specify ad hoc recipe actions We are reusing the buildspec syntax for that. --- libbuild2/algorithm.cxx | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) (limited to 'libbuild2/algorithm.cxx') diff --git a/libbuild2/algorithm.cxx b/libbuild2/algorithm.cxx index 0924540..6ea1e1f 100644 --- a/libbuild2/algorithm.cxx +++ b/libbuild2/algorithm.cxx @@ -335,20 +335,32 @@ namespace build2 // the correct semantics. auto b (t.adhoc_recipes.begin ()), e (t.adhoc_recipes.end ()); - auto i (find_if (b, e, - [a, &t] (const adhoc_recipe& r) - { - return r.action == a && - r.rule->match (a, t, string () /* hint */, nullopt); - })); + auto i (find_if ( + b, e, + [a, &t] (const adhoc_recipe& r) + { + auto& as (r.actions); + return (find (as.begin (), as.end (), a) != as.end () && + r.rule->match (a, t, string () /* hint */, nullopt)); + })); if (i == e) - i = find_if (b, e, - [a, &t] (const adhoc_recipe& r) - { - return r.action != a && - r.rule->match (a, t, string () /* hint */, r.action); - }); + i = find_if ( + b, e, + [a, &t] (const adhoc_recipe& r) + { + // See the adhoc_rule::match() documentation for details. + // + auto& as (r.actions); + if (find (as.begin (), as.end (), a) == as.end ()) + { + for (auto ra: as) + if (r.rule->match (a, t, string () /* hint */, ra)) + return true; + } + return false; + }); + if (i != e) return &i->rule->rule_match; } -- cgit v1.1