From 3cc5e3bd441fc9d18fece3d9e99fae75c78438e7 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 28 Jun 2018 09:44:15 +0200 Subject: Implement support for excluded and ad hoc prerequisites The inclusion/exclusion is controlled via the 'include' prerequisite-specific variable. Valid values are: false - exclude true - include adhoc - include but treat as an ad hoc input For example: lib{foo}: cxx{win32-utility}: include = ($cxx.targe.class == 'windows') exe{bar}: libs{plugin}: include = adhoc --- build2/algorithm.cxx | 38 ++++++++++++++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 4 deletions(-) (limited to 'build2/algorithm.cxx') diff --git a/build2/algorithm.cxx b/build2/algorithm.cxx index 7e68a36..5dc3637 100644 --- a/build2/algorithm.cxx +++ b/build2/algorithm.cxx @@ -668,13 +668,20 @@ namespace build2 size_t i (pts.size ()); // Index of the first to be added. for (auto&& p: forward (r)) { + // Ignore excluded. + // + include_type pi (include (a, t, p)); + + if (!pi) + continue; + const target& pt (search (t, p)); if (s != nullptr && !pt.in (*s)) continue; match_async (a, pt, target::count_busy (), t[a].task_count); - pts.push_back (&pt); + pts.push_back (prerequisite_target (&pt, pi)); } wg.wait (); @@ -737,11 +744,12 @@ namespace build2 // Instantiate only for what we need. // template void - match_members (action, target&, const target* const*, size_t); + match_members (action, target&, + const target* const*, size_t); template void - match_members ( - action, target&, prerequisite_target const*, size_t); + match_members (action, target&, + prerequisite_target const*, size_t); const fsdir* inject_fsdir (action a, target& t, bool parent) @@ -1567,6 +1575,21 @@ namespace build2 return t.executed_state (a); } + static inline bool + adhoc_member (const target*&) + { + return false; + } + + static inline bool + adhoc_member (prerequisite_target& pt) + { + if (pt.adhoc) + pt.target = nullptr; + + return pt.adhoc; + } + template target_state straight_execute_members (action a, atomic_count& tc, @@ -1615,6 +1638,8 @@ namespace build2 sched.wait (target::count_executed (), tc, scheduler::work_none); r |= mt.executed_state (a); + + adhoc_member (ts[i]); } return r; @@ -1662,6 +1687,8 @@ namespace build2 sched.wait (target::count_executed (), tc, scheduler::work_none); r |= mt.executed_state (a); + + adhoc_member (ts[i]); } return r; @@ -1766,6 +1793,9 @@ namespace build2 } } + if (adhoc_member (pts[i])) + continue; + if (rt == nullptr && pt.is_a (*tt)) rt = &pt; } -- cgit v1.1