diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2020-05-08 15:43:13 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2020-05-27 08:35:29 +0200 |
commit | 9a0f07035b34a356ce9b5601d71d388595762184 (patch) | |
tree | 9a1d52a23655529706d2f6ec669083e178b37aed /libbuild2/algorithm.cxx | |
parent | 66b6e20659a0d611e89adde85cd7bcb34a92a2c7 (diff) |
Generalize to adhoc_rule/adhoc_script_rule
Diffstat (limited to 'libbuild2/algorithm.cxx')
-rw-r--r-- | libbuild2/algorithm.cxx | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/libbuild2/algorithm.cxx b/libbuild2/algorithm.cxx index b4ff22a..ceb18e4 100644 --- a/libbuild2/algorithm.cxx +++ b/libbuild2/algorithm.cxx @@ -331,8 +331,31 @@ namespace build2 dr << info << "while matching ad hoc recipe to " << diag_do (a, t); }); - if (adhoc_rule::instance.match (a, t, string () /* hint */)) - return &adhoc_rule::match_instance; + // @@ TODO: + // + // 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. + + 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); + })); + + 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); + }); + if (i != e) + return &i->rule->rule_match; } // If this is an outer operation (Y-for-X), then we look for rules |