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.hxx | 49 ++++++++++++++++++++++++++++--------------------- 1 file changed, 28 insertions(+), 21 deletions(-) (limited to 'libbuild2/dyndep.hxx') diff --git a/libbuild2/dyndep.hxx b/libbuild2/dyndep.hxx index ee9c1dd..1de2858 100644 --- a/libbuild2/dyndep.hxx +++ b/libbuild2/dyndep.hxx @@ -228,40 +228,41 @@ namespace build2 const srcout_map& = {}); // Find or insert a target file path as a target of the specified type, - // make it a member of the specified (non-ad hoc) mtime target group, - // set its path, and match it with group_recipe. + // make it a member of the specified (non-ad hoc) mtime target group and + // set its path. Return the target and an indication of whether it was + // made a member (can only be false if a filter is provided; see below). // // The file path must be absolute and normalized. Note that this function // assumes that this member can only be matched via this group. The group // type must have the target_type::flag::dyn_members flag. // - // Note: we can split this function into {enter,match}_group_member() - // if necessary. + // If specified, the group_filter function is called on the target before + // making it a group member, skipping it if this function returns false. + // Note that the filter is skipped if the target is newly inserted (the + // filter is meant to be used to skip duplicates). // - static const file& + using group_filter_func = bool (mtime_target& g, const file&); + + static pair inject_group_member (action, const scope& base, mtime_target&, - path, const target_type&); + path, + const target_type&, + const function& = nullptr); template - static const T& - inject_group_member (action a, const scope& bs, mtime_target& g, path f) + static pair + inject_group_member (action a, const scope& bs, mtime_target& g, + path f, + const function& filter = nullptr) { return inject_group_member ( - a, bs, g, move (f), T::static_type).template as (); + a, bs, g, move (f), T::static_type, filter).template as (); } // As above but the target type is determined using the map_extension // function if specified, falling back to the fallback type if unable to - // (the what argument is used for diagnostics during this process). Return - // the target and an indication of whether it was made a member. + // (the what argument is used for diagnostics during this process). // - // If specified, the group_filter function is called on the target before - // making it a group member, skipping it if this function returns false. - // Note that the filter is skipped if the target is newly inserted (the - // filter is meant to be used to skip duplicates). - // - using group_filter_func = bool (mtime_target& g, const file&); - static pair inject_group_member (const char* what, action, const scope& base, mtime_target& g, @@ -275,13 +276,19 @@ namespace build2 // specified ad hoc group unless it already is, and set its path. Return // the target and an indication of whether it was added as a member. // - // The target type is determined using the map_extension function if - // specified, falling back to the fallback type if unable to. - // // The file path must be absolute and normalized. Note that this function // assumes that this target can only be known as a member of this group. // static pair + inject_adhoc_group_member (action, const scope& base, target& g, + path, + const target_type&); + + // As above but the target type is determined using the map_extension + // function if specified, falling back to the fallback type if unable to + // (the what argument is used for diagnostics during this process). + // + static pair inject_adhoc_group_member (const char* what, action, const scope& base, target& g, path, -- cgit v1.1