diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2018-06-28 09:44:15 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2018-06-28 09:44:15 +0200 |
commit | 3cc5e3bd441fc9d18fece3d9e99fae75c78438e7 (patch) | |
tree | a9a08c453370847e0d352d47e19fbfcb7cc757ef /build2/algorithm.cxx | |
parent | c0f72d47fc25981dcc1f55e12dfa0fdba7b70242 (diff) |
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
Diffstat (limited to 'build2/algorithm.cxx')
-rw-r--r-- | build2/algorithm.cxx | 38 |
1 files changed, 34 insertions, 4 deletions
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> (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<const target*> (action, target&, const target* const*, size_t); + match_members<const target*> (action, target&, + const target* const*, size_t); template void - match_members<prerequisite_target> ( - action, target&, prerequisite_target const*, size_t); + match_members<prerequisite_target> (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 <typename T> 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; } |