From d9745e79083e12a2c3eb129a20fc20be3607a4c3 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 2 Dec 2021 14:05:59 +0200 Subject: Automatically register pattern rules for dist meta-operation We need to do this in order to inject additional pattern prerequisites which may "pull" additional sources into the distribution. --- libbuild2/parser.cxx | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) (limited to 'libbuild2/parser.cxx') diff --git a/libbuild2/parser.cxx b/libbuild2/parser.cxx index d50f86f..9c26f74 100644 --- a/libbuild2/parser.cxx +++ b/libbuild2/parser.cxx @@ -1108,12 +1108,16 @@ namespace build2 for (shared_ptr& pr: recipes) { - adhoc_rule& r (*pr); - r.pattern = &rp; // Connect recipe to pattern. + pr->pattern = &rp; // Connect recipe to pattern. rp.rules.push_back (move (pr)); + } + + // Register this adhoc rule for all its actions. + // + for (shared_ptr& pr: rp.rules) + { + adhoc_rule& r (*pr); - // Register this adhoc rule for all its actions. - // for (action a: r.actions) { // This covers both duplicate recipe actions withing the rule @@ -1146,6 +1150,26 @@ namespace build2 scope_->rules.insert ( a.meta_operation (), 0, *ttype, rp.rule_name, rp.fallback_rule_); + + // We also register for the dist meta-operation in order to + // inject additional prerequisites which may "pull" additional + // sources into the distribution. Unless there is an explicit + // recipe for dist. + // + if (a.meta_operation () == perform_id) + { + action da (dist_id, a.operation ()); + + for (shared_ptr& pr: rp.rules) + for (action a: pr->actions) + if (da == a) + goto skip; + + scope_->rules.insert (da, *ttype, rp.rule_name, r); + + skip: + ; + } } } } -- cgit v1.1