aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/dyndep.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2022-02-09 10:13:15 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2022-02-09 10:19:46 +0200
commit36e62584b33b5c168b8b42564d7f45b2150eef17 (patch)
treea7faef844b83e9e94ab7c7422e8e2b989bd73db5 /libbuild2/dyndep.cxx
parentc285dafe9e2b7e4bba3fddad3fa254e4bdbb02d3 (diff)
Add dyndep_rule::inject_group_member()
Diffstat (limited to 'libbuild2/dyndep.cxx')
-rw-r--r--libbuild2/dyndep.cxx45
1 files changed, 45 insertions, 0 deletions
diff --git a/libbuild2/dyndep.cxx b/libbuild2/dyndep.cxx
index 73fc8eb..f1fc5ec 100644
--- a/libbuild2/dyndep.cxx
+++ b/libbuild2/dyndep.cxx
@@ -799,4 +799,49 @@ namespace build2
false /* insert */,
map_ext, fallback, pfx_map, so_map);
}
+
+ const file& dyndep_rule::
+ inject_group_member (action a, const scope& bs, mtime_target& g,
+ path p, const target_type& tt)
+ {
+ path n (p.leaf ());
+ string e (n.extension ());
+
+ // Assume nobody else can insert these members (seems reasonable seeing
+ // that their names are dynamically discovered).
+ //
+ auto l (search_new_locked (
+ bs.ctx,
+ tt,
+ p.directory (),
+ dir_path (), // Always in out.
+ move (n.make_base ()).string (),
+ &e,
+ &bs));
+
+ const file& t (l.first.as<file> ()); // Note: non-const only if have lock.
+
+ if (l.second)
+ {
+ l.first.group = &g;
+ l.second.unlock ();
+ t.path (move (p)); // Only do this once.
+ }
+ else
+ // Must have been already done (e.g., on previous operation in a
+ // batch).
+ //
+ assert (t.group == &g);
+
+ // This shouldn't fail since we are the only ones that should be matching
+ // this target.
+ //
+ target_lock tl (lock (a, t));
+ assert (tl);
+
+ match_inc_dependents (a, g);
+ match_recipe (tl, group_recipe);
+
+ return t;
+ }
}