diff options
Diffstat (limited to 'libbuild2/algorithm.cxx')
-rw-r--r-- | libbuild2/algorithm.cxx | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/libbuild2/algorithm.cxx b/libbuild2/algorithm.cxx index ef1a78d..9b2162e 100644 --- a/libbuild2/algorithm.cxx +++ b/libbuild2/algorithm.cxx @@ -318,12 +318,28 @@ namespace build2 // Return the matching rule or NULL if no match and try_match is true. // const rule_match* - match_impl (action a, target& t, const rule* skip, bool try_match) + match_rule (action a, target& t, const rule* skip, bool try_match) { + // First check for an ad hoc recipe. + // + if (!t.adhoc_recipes.empty ()) + { + auto df = make_diag_frame ( + [a, &t](const diag_record& dr) + { + if (verb != 0) + 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; + } + // If this is an outer operation (Y-for-X), then we look for rules - // registered for the outer id (X). Note that we still pass the original - // action to the rule's match() function so that it can distinguish - // between a pre/post operation (Y-for-X) and the actual operation (X). + // registered for the outer id (X; yes, it's really outer). Note that we + // still pass the original action to the rule's match() function so that + // it can distinguish between a pre/post operation (Y-for-X) and the + // actual operation (X). // meta_operation_id mo (a.meta_operation ()); operation_id o (a.inner () ? a.operation () : a.outer_operation ()); @@ -561,7 +577,7 @@ namespace build2 t.prerequisite_targets[a].clear (); if (a.inner ()) t.clear_data (); - const rule_match* r (match_impl (a, t, nullptr, try_match)); + const rule_match* r (match_rule (a, t, nullptr, try_match)); assert (l.offset != target::offset_tried); // Should have failed. |