From de2daaa41ec6064181e6b9e73a34c32cd0008242 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 30 May 2023 05:51:23 +0200 Subject: Store dynamic group member types in depdb, use in clean --- libbuild2/dyndep.cxx | 71 +++++++++++++++++++++++++++++++++++----------------- 1 file changed, 48 insertions(+), 23 deletions(-) (limited to 'libbuild2/dyndep.cxx') diff --git a/libbuild2/dyndep.cxx b/libbuild2/dyndep.cxx index 9c0f8a8..6d1a32c 100644 --- a/libbuild2/dyndep.cxx +++ b/libbuild2/dyndep.cxx @@ -910,9 +910,11 @@ namespace build2 return pair (t, true); } - const file& dyndep_rule:: + pair dyndep_rule:: inject_group_member (action a, const scope& bs, mtime_target& g, - path f, const target_type& tt) + path f, + const target_type& tt, + const function& filter) { path n (f.leaf ()); string e (n.extension ()); @@ -921,7 +923,7 @@ namespace build2 return inject_group_member_impl (a, bs, g, move (f), move (n).string (), move (e), tt, - nullptr /* filter */).first; + filter); } static const target_type& @@ -943,7 +945,7 @@ namespace build2 { diag_record dr (fail); - dr << "mapping of " << what << " target file " << f + dr << "mapping of " << what << " target path " << f << " to target type is ambiguous"; for (const target_type* tt: tts) @@ -954,7 +956,7 @@ namespace build2 if (!tt.is_a ()) { - fail << what << " target file " << f << " mapped to non-file-based " + fail << what << " target path " << f << " mapped to non-file-based " << "target type " << tt.name << "{}"; } @@ -984,22 +986,11 @@ namespace build2 filter); } - pair dyndep_rule:: - inject_adhoc_group_member (const char* what, - action, const scope& bs, target& t, - path f, - const function& map_ext, - const target_type& fallback) + pair + inject_adhoc_group_member_impl (action, const scope& bs, target& t, + path f, string n, string e, + const target_type& tt) { - path n (f.leaf ()); - string e (n.extension ()); - n.make_base (); - - // Map extension to the target type, falling back to the fallback type. - // - const target_type& tt ( - map_target_type (what, bs, f, n.string (), e, map_ext, fallback)); - // Assume nobody else can insert these members (seems reasonable seeing // that their names are dynamically discovered). // @@ -1008,7 +999,7 @@ namespace build2 tt, f.directory (), dir_path (), // Always in out. - move (n).string (), + move (n), &e, &bs)); @@ -1040,8 +1031,8 @@ namespace build2 return pair (*ft, false); if (!l.second) - fail << "dynamic " << what << " target " << *ft << " already exists " - << "and cannot be made ad hoc member of group " << t; + fail << "dynamic target " << *ft << " already exists and cannot be " + << "made ad hoc member of group " << t; ft->group = &t; l.second.unlock (); @@ -1056,4 +1047,38 @@ namespace build2 return pair (*ft, true); } + + pair dyndep_rule:: + inject_adhoc_group_member (action a, const scope& bs, target& t, + path f, + const target_type& tt) + { + path n (f.leaf ()); + string e (n.extension ()); + n.make_base (); + + return inject_adhoc_group_member_impl ( + a, bs, t, move (f), move (n).string (), move (e), tt); + } + + pair dyndep_rule:: + inject_adhoc_group_member (const char* what, + action a, const scope& bs, target& t, + path f, + const function& map_ext, + const target_type& fallback) + { + path n (f.leaf ()); + string e (n.extension ()); + n.make_base (); + + // Map extension to the target type, falling back to the fallback type. + // + const target_type& tt ( + map_target_type (what, bs, f, n.string (), e, map_ext, fallback)); + + + return inject_adhoc_group_member_impl ( + a, bs, t, move (f), move (n).string (), move (e), tt); + } } -- cgit v1.1