diff options
Diffstat (limited to 'libbuild2/scope.ixx')
-rw-r--r-- | libbuild2/scope.ixx | 43 |
1 files changed, 39 insertions, 4 deletions
diff --git a/libbuild2/scope.ixx b/libbuild2/scope.ixx index e123e4a..5975c76 100644 --- a/libbuild2/scope.ixx +++ b/libbuild2/scope.ixx @@ -146,9 +146,11 @@ namespace build2 } inline target_key scope:: - find_target_key (name& n, name& o, const location& loc) const + find_target_key (name& n, name& o, + const location& loc, + const target_type* tt) const { - auto p (find_target_type (n, o, loc)); + auto p (find_target_type (n, o, loc, tt)); return target_key { &p.first, &n.dir, @@ -158,9 +160,11 @@ namespace build2 } inline prerequisite_key scope:: - find_prerequisite_key (name& n, name& o, const location& loc) const + find_prerequisite_key (name& n, name& o, + const location& loc, + const target_type* tt) const { - auto p (find_prerequisite_type (n, o, loc)); + auto p (find_prerequisite_type (n, o, loc, tt)); return prerequisite_key { n.proj, { @@ -173,6 +177,37 @@ namespace build2 this}; } + template <typename T> + inline void scope:: + insert_rule (meta_operation_id mid, operation_id oid, + string name, + const rule& r) + { + if (mid != 0) + rules.insert<T> (mid, oid, move (name), r); + else + { + auto& ms (root_scope ()->root_extra->meta_operations); + + for (size_t i (1), n (ms.size ()); i != n; ++i) + { + if (ms[i] != nullptr) + { + // Skip a few well-known meta-operations that cannot possibly + // trigger a rule match. + // + mid = static_cast<meta_operation_id> (i); + + if (mid != noop_id && + mid != info_id && + mid != create_id && + mid != disfigure_id) + rules.insert<T> (mid, oid, name, r); + } + } + } + } + inline dir_path src_out (const dir_path& out, const scope& r) { |