diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2020-06-08 08:12:54 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2020-06-08 08:12:54 +0200 |
commit | 8e42d1ec329ac16ec5ae9692f18cdb0f2444d2fb (patch) | |
tree | 386ea3472fa382727d1f377c0c7090f81ddd292a /libbuild2/algorithm.cxx | |
parent | fb56fc798110c8ee9685bec156b21f1f87aca121 (diff) |
Fix handling of inner/outer operations in ad hoc recipes machinery
Diffstat (limited to 'libbuild2/algorithm.cxx')
-rw-r--r-- | libbuild2/algorithm.cxx | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/libbuild2/algorithm.cxx b/libbuild2/algorithm.cxx index 6ea1e1f..077bdf2 100644 --- a/libbuild2/algorithm.cxx +++ b/libbuild2/algorithm.cxx @@ -326,33 +326,34 @@ namespace build2 dr << info << "while matching ad hoc recipe to " << diag_do (a, t); }); - // @@ TODO: + // The action could be Y-for-X while the ad hoc recipes are always for + // X. So strip the Y-for part for comparison (but not for the match() + // calls; see below for the hairy inner/outer semantics details). // - // If action is Y-for-X, how would we distinguish between X and Y-for-X? - // See match_rule() for the hairy details. We could start with - // supporting just the inner case. Or we could try to just match an - // inner rule by default? I think need a clear use-case to see what's - // the correct semantics. + action ca (a.outer () + ? action (a.meta_operation (), a.outer_operation ()) + : a); auto b (t.adhoc_recipes.begin ()), e (t.adhoc_recipes.end ()); auto i (find_if ( b, e, - [a, &t] (const adhoc_recipe& r) + [a, ca, &t] (const adhoc_recipe& r) { auto& as (r.actions); - return (find (as.begin (), as.end (), a) != as.end () && + return (find (as.begin (), as.end (), ca) != as.end () && r.rule->match (a, t, string () /* hint */, nullopt)); })); if (i == e) i = find_if ( b, e, - [a, &t] (const adhoc_recipe& r) + [a, ca, &t] (const adhoc_recipe& r) { - // See the adhoc_rule::match() documentation for details. + // See the adhoc_rule::match() documentation for details on what's + // going on here. // auto& as (r.actions); - if (find (as.begin (), as.end (), a) == as.end ()) + if (find (as.begin (), as.end (), ca) == as.end ()) { for (auto ra: as) if (r.rule->match (a, t, string () /* hint */, ra)) |