aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/algorithm.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2020-06-05 06:36:30 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2020-06-05 06:36:30 +0200
commit9ec2bdd87659438b4aa021a10c4a4977ef77118e (patch)
tree12580b4d0b82bce80047b067c3bb221b49be7449 /libbuild2/algorithm.cxx
parentd280946474568925016359be742b59fd6c000c52 (diff)
Add ability to specify ad hoc recipe actions
We are reusing the buildspec syntax for that.
Diffstat (limited to 'libbuild2/algorithm.cxx')
-rw-r--r--libbuild2/algorithm.cxx36
1 files changed, 24 insertions, 12 deletions
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;
}