From 36e62584b33b5c168b8b42564d7f45b2150eef17 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 9 Feb 2022 10:13:15 +0200 Subject: Add dyndep_rule::inject_group_member() --- libbuild2/dyndep.cxx | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) (limited to 'libbuild2/dyndep.cxx') 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 ()); // 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; + } } -- cgit v1.1