From e3f077ba7584f65561e21ca195215abd341b9147 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 7 Feb 2022 07:59:48 +0200 Subject: Add support for meta-operation wildcard in scope::insert_rule() --- libbuild2/scope.hxx | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'libbuild2/scope.hxx') diff --git a/libbuild2/scope.hxx b/libbuild2/scope.hxx index f82db72..e3ebdef 100644 --- a/libbuild2/scope.hxx +++ b/libbuild2/scope.hxx @@ -423,13 +423,37 @@ namespace build2 rules.insert (a, move (hint), r); } + // 0 meta-operation id is treated as an (emulated) wildcard. + // + // Emulated means that we just iterate over all the meta-operations known + // to this project (and they should all be known at this point) and + // register the rule for each of them. + // template void insert_rule (meta_operation_id mid, operation_id oid, string hint, const rule& r) { - rules.insert (mid, oid, move (hint), r); + if (mid != 0) + rules.insert (mid, oid, move (hint), r); + else + { + auto& ms (root_scope ()->root_extra->meta_operations); + + for (size_t i (1), n (ms.size ()); i != n; ++i) + { + // Skip a few well-known meta-operations that cannot possibly + // trigger a rule match. + // + if (ms[i] != nullptr && + i != noop_id && + i != info_id && + i != create_id && + i != disfigure_id) + rules.insert (i, oid, hint, r); + } + } } // Operation callbacks. -- cgit v1.1