aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/algorithm.ixx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2022-10-19 10:26:22 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2022-10-19 10:26:22 +0200
commit18394bc05dc4cadb2dc193cfeb78598c70447869 (patch)
tree2b3d794305dc5d950f9c05094b80c89b93e5fd25 /libbuild2/algorithm.ixx
parentb408d19f614b47670cd0a0def501266f0d7689b5 (diff)
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.
Diffstat (limited to 'libbuild2/algorithm.ixx')
-rw-r--r--libbuild2/algorithm.ixx20
1 files changed, 17 insertions, 3 deletions
diff --git a/libbuild2/algorithm.ixx b/libbuild2/algorithm.ixx
index 417a10e..7c87a72 100644
--- a/libbuild2/algorithm.ixx
+++ b/libbuild2/algorithm.ixx
@@ -424,6 +424,19 @@ namespace build2
return r;
}
+ inline target_state
+ match_direct_sync (action a, const target& t, bool fail)
+ {
+ assert (t.ctx.phase == run_phase::match);
+
+ target_state r (match_impl (a, t, 0, nullptr).second);
+
+ if (fail && r == target_state::failed)
+ throw failed ();
+
+ return r;
+ }
+
inline pair<bool, target_state>
try_match_sync (action a, const target& t, bool fail)
{
@@ -787,7 +800,7 @@ namespace build2
execute_direct_impl (action, const target&, size_t, atomic_count*);
inline target_state
- execute_direct_sync (action a, const target& t)
+ execute_direct_sync (action a, const target& t, bool fail)
{
target_state r (execute_direct_impl (a, t, 0, nullptr));
@@ -800,7 +813,7 @@ namespace build2
r = t.executed_state (a, false);
}
- if (r == target_state::failed)
+ if (r == target_state::failed && fail)
throw failed ();
return r;
@@ -960,8 +973,9 @@ namespace build2
p.first, static_cast<const T&> (p.second));
}
+ template <typename T>
inline target_state
- execute_members (action a, const target& t, const target* ts[], size_t n)
+ execute_members (action a, const target& t, T ts[], size_t n)
{
return t.ctx.current_mode == execution_mode::first
? straight_execute_members (a, t, ts, n, 0)