aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/scope.hxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2022-02-07 07:59:48 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2022-02-07 07:59:48 +0200
commite3f077ba7584f65561e21ca195215abd341b9147 (patch)
treed4965d7e3a15ebed181f1a1c37c433cde80fae2d /libbuild2/scope.hxx
parent9699e205dc55a9e2de18f56aabad8feb46613b1f (diff)
Add support for meta-operation wildcard in scope::insert_rule()
Diffstat (limited to 'libbuild2/scope.hxx')
-rw-r--r--libbuild2/scope.hxx26
1 files changed, 25 insertions, 1 deletions
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<T> (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 <typename T>
void
insert_rule (meta_operation_id mid, operation_id oid,
string hint,
const rule& r)
{
- rules.insert<T> (mid, oid, move (hint), r);
+ if (mid != 0)
+ rules.insert<T> (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<T> (i, oid, hint, r);
+ }
+ }
}
// Operation callbacks.