From e0b72f24c3e7ea14dc8da54dc0bfc62f43334f3b Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 15 May 2019 12:57:38 +0200 Subject: Cleanup clean_extra() mess (pun intended) --- build2/algorithm.hxx | 44 ++++++++++++++++++++++++++++++-------------- 1 file changed, 30 insertions(+), 14 deletions(-) (limited to 'build2/algorithm.hxx') diff --git a/build2/algorithm.hxx b/build2/algorithm.hxx index e3473ad..b246c37 100644 --- a/build2/algorithm.hxx +++ b/build2/algorithm.hxx @@ -190,11 +190,13 @@ namespace build2 // or already existing target. The member directories (dir and out) are // expected to be absolute and normalized. // - // Note that here and in find_adhoc_member() below we use target type (as - // opposed to, say, type and name) as the member's identity. This fits our - // current needs where every (rule-managed) ad hoc member has a unique - // target type and allows us to support things like overriding the ad hoc - // member name by the user. + // Note that here and in find_adhoc_member() below (as well as in + // perform_clean_extra()) we use target type (as opposed to, say, type and + // name) as the member's identity. This fits our current needs where every + // (rule-managed) ad hoc member has a unique target type and we have no need + // for multiple members of the same type. This also allows us to support + // things like changing the ad hoc member name by declaring it in a + // buildfile. // target& add_adhoc_member (target&, @@ -691,30 +693,44 @@ namespace build2 // paths or "path derivation directives". The directive string can be NULL, // or empty in which case it is ignored. If the last character in a // directive is '/', then the resulting path is treated as a directory - // rather than a file. The directive can start with zero or more '-' + // rather than a file. The directive can start with zero or more '-' // characters which indicate the number of extensions that should be // stripped before the new extension (if any) is added (so if you want to // strip the extension, specify just "-"). For example: // - // clean_extra (a, t, {".d", ".dlls/", "-.dll"}); + // perform_clean_extra (a, t, {".d", ".dlls/", "-.dll"}); // // The extra files/directories are removed first in the specified order // followed by the ad hoc group member, then target itself, and, finally, // the prerequisites in the reverse order. // - // You can also clean extra files derived from ad hoc group members. + // You can also clean extra files derived from ad hoc group members that are + // "indexed" using using their target types (see add/find_adhoc_member() for + // details). // - // Note that if the target path is empty then it is assumed "unreal" and - // is not cleaned (but its prerequisites/members still are). + // Note that if the target path is empty then it is assumed "unreal" and is + // not cleaned (but its prerequisites/members still are). // + using clean_extras = small_vector; + + struct clean_adhoc_extra + { + const target_type& type; + clean_extras extras; + }; + + using clean_adhoc_extras = small_vector; + target_state - clean_extra (action, const file&, - initializer_list> extra); + perform_clean_extra (action, const file&, + const clean_extras&, + const clean_adhoc_extras& = {}); inline target_state - clean_extra (action a, const file& f, initializer_list extra) + perform_clean_extra (action a, const file& f, + initializer_list e) { - return clean_extra (a, f, {extra}); + return perform_clean_extra (a, f, clean_extras (e)); } // Update/clean a backlink issuing appropriate diagnostics at appropriate -- cgit v1.1