From 18394bc05dc4cadb2dc193cfeb78598c70447869 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 19 Oct 2022 10:26:22 +0200 Subject: Add support for post hoc prerequisites Unlike normal and ad hoc prerequisites, a post hoc prerequisite is built after the target, not before. It may also form a dependency cycle together with normal/ad hoc prerequisites. In other words, all this form of dependency guarantees is that a post hoc prerequisite will be built if its dependent target is built. See the NEWS file for details and an example. --- libbuild2/algorithm.hxx | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'libbuild2/algorithm.hxx') diff --git a/libbuild2/algorithm.hxx b/libbuild2/algorithm.hxx index e558d3a..756c3fe 100644 --- a/libbuild2/algorithm.hxx +++ b/libbuild2/algorithm.hxx @@ -195,6 +195,8 @@ namespace build2 explicit operator bool () const {return target != nullptr;} + // Note: achieved offset is preserved. + // void unlock (); @@ -374,6 +376,12 @@ namespace build2 pair match_sync (action, const target&, unmatch); + // As above but without incrementing the target's dependents count. Should + // be executed with execute_direct_*(). + // + target_state + match_direct_sync (action, const target&, bool fail = true); + // Start asynchronous match. Return target_state::postponed if the // asynchronous operation has been started and target_state::busy if the // target has already been busy. Regardless of the result, match_complete() @@ -486,11 +494,11 @@ namespace build2 // target pointers are skipped. // LIBBUILD2_SYMEXPORT void - match_members (action, target&, const target* const*, size_t); + match_members (action, const target&, const target* const*, size_t); template inline void - match_members (action a, target& t, const target* (&ts)[N]) + match_members (action a, const target& t, const target* (&ts)[N]) { match_members (a, t, ts, N); } @@ -501,7 +509,7 @@ namespace build2 // LIBBUILD2_SYMEXPORT void match_members (action a, - target& t, + const target& t, prerequisite_targets& ts, size_t start = 0, pair include = {0, 0}); @@ -613,7 +621,7 @@ namespace build2 // translates target_state::failed to the failed exception. // target_state - execute_direct_sync (action, const target&); + execute_direct_sync (action, const target&, bool fail = true); target_state execute_direct_async (action, const target&, @@ -795,8 +803,9 @@ namespace build2 // Call straight or reverse depending on the current mode. // + template target_state - execute_members (action, const target&, const target*[], size_t); + execute_members (action, const target&, T[], size_t); template inline target_state -- cgit v1.1