From d0385d4be5f6a483de2d6b1a506d576d08ed547a Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 14 Feb 2024 09:42:57 +0200 Subject: Add search_prerequisite*() variants of match_prerequisite*() versions --- libbuild2/algorithm.ixx | 76 +++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 68 insertions(+), 8 deletions(-) (limited to 'libbuild2/algorithm.ixx') diff --git a/libbuild2/algorithm.ixx b/libbuild2/algorithm.ixx index de175eb..836dbed 100644 --- a/libbuild2/algorithm.ixx +++ b/libbuild2/algorithm.ixx @@ -745,12 +745,16 @@ namespace build2 } LIBBUILD2_SYMEXPORT void - match_prerequisites (action, target&, const match_search&, const scope*); + match_prerequisites (action, target&, + const match_search&, + const scope*, + bool search_only); LIBBUILD2_SYMEXPORT void match_prerequisite_members (action, target&, const match_search_member&, - const scope*); + const scope*, + bool search_only); inline void match_prerequisites (action a, target& t, const match_search& ms) @@ -761,7 +765,21 @@ namespace build2 ms, (a.operation () != clean_id || t.is_a () ? nullptr - : &t.root_scope ())); + : &t.root_scope ()), + false); + } + + inline void + search_prerequisites (action a, target& t, const match_search& ms) + { + match_prerequisites ( + a, + t, + ms, + (a.operation () != clean_id || t.is_a () + ? nullptr + : &t.root_scope ()), + true); } inline void @@ -769,7 +787,37 @@ namespace build2 const match_search_member& msm) { if (a.operation () != clean_id || t.is_a ()) - match_prerequisite_members (a, t, msm, nullptr); + match_prerequisite_members (a, t, msm, nullptr, false); + else + { + // Note that here we don't iterate over members even for see-through + // groups since the group target should clean eveything up. A bit of an + // optimization. + // + // @@ TMP: I wonder if this still holds for the new group semantics + // we have in Qt automoc? Also below. + // + match_search ms ( + msm + ? [&msm] (action a, + const target& t, + const prerequisite& p, + include_type i) + { + return msm (a, t, prerequisite_member {p, nullptr}, i); + } + : match_search ()); + + match_prerequisites (a, t, ms, &t.root_scope (), false); + } + } + + inline void + search_prerequisite_members (action a, target& t, + const match_search_member& msm) + { + if (a.operation () != clean_id || t.is_a ()) + match_prerequisite_members (a, t, msm, nullptr, true); else { // Note that here we don't iterate over members even for see-through @@ -777,7 +825,7 @@ namespace build2 // optimization. // // @@ TMP: I wonder if this still holds for the new group semantics - // we have in Qt automoc? + // we have in Qt automoc? Also above. // match_search ms ( msm @@ -790,20 +838,32 @@ namespace build2 } : match_search ()); - match_prerequisites (a, t, ms, &t.root_scope ()); + match_prerequisites (a, t, ms, &t.root_scope (), true); } } inline void match_prerequisites (action a, target& t, const scope& s) { - match_prerequisites (a, t, nullptr, &s); + match_prerequisites (a, t, nullptr, &s, false); + } + + inline void + search_prerequisites (action a, target& t, const scope& s) + { + match_prerequisites (a, t, nullptr, &s, true); } inline void match_prerequisite_members (action a, target& t, const scope& s) { - match_prerequisite_members (a, t, nullptr, &s); + match_prerequisite_members (a, t, nullptr, &s, false); + } + + inline void + search_prerequisite_members (action a, target& t, const scope& s) + { + match_prerequisite_members (a, t, nullptr, &s, true); } LIBBUILD2_SYMEXPORT target_state -- cgit v1.1