diff options
-rw-r--r-- | libbuild2/algorithm.cxx | 72 | ||||
-rw-r--r-- | libbuild2/algorithm.ixx | 4 |
2 files changed, 23 insertions, 53 deletions
diff --git a/libbuild2/algorithm.cxx b/libbuild2/algorithm.cxx index 4c404c6..bd89fc5 100644 --- a/libbuild2/algorithm.cxx +++ b/libbuild2/algorithm.cxx @@ -1150,6 +1150,10 @@ namespace build2 { match_inc_dependents (a, g); match_recipe (l, group_recipe); + + // Note: no need to call match_posthoc() since an ad hoc member + // has no own prerequisites and the group's ones will be matched + // by the group. } } else @@ -1213,6 +1217,13 @@ namespace build2 // set_recipe (l, apply_impl (a, t, *s.rule)); l.offset = target::offset_applied; + + if (t.has_group_prerequisites ()) // Ok since already matched. + { + if (!match_posthoc (a, t)) + s.state = target_state::failed; + } + break; } case target::offset_applied: @@ -1249,13 +1260,16 @@ namespace build2 } catch (const failed&) { + s.state = target_state::failed; + l.offset = target::offset_applied; + } + + if (s.state == target_state::failed) + { // As a sanity measure clear the target data since it can be incomplete // or invalid (mark()/unmark() should give you some ideas). // clear_target (a, t); - - s.state = target_state::failed; - l.offset = target::offset_applied; } return make_pair (true, s.state); @@ -1302,23 +1316,7 @@ namespace build2 return make_pair (false, target_state::unknown); if (task_count == nullptr) - { - bool applied (l.offset == target::offset_applied); - - pair<bool, target_state> r ( - match_impl_impl (l, options, false /* step */, try_match)); - - if (r.first && - r.second != target_state::failed && - (!applied && l.offset == target::offset_applied) && - ct.has_group_prerequisites ()) // Already matched. - { - if (!match_posthoc (a, *l.target)) - r.second = target_state::failed; - } - - return r; - } + return match_impl_impl (l, options, false /* step */, try_match); // Pass "disassembled" lock since the scheduler queue doesn't support // task destruction. @@ -1353,17 +1351,7 @@ namespace build2 // Note: target_lock must be unlocked within the match phase. // target_lock l {a, &t, offset, first}; // Reassemble. - - bool applied (l.offset == target::offset_applied); - - pair<bool, target_state> r ( - match_impl_impl (l, options, false /* step */, try_match)); - - if (r.first && - r.second != target_state::failed && - (!applied && l.offset == target::offset_applied) && - t.has_group_prerequisites ()) // Already matched. - match_posthoc (a, t); + match_impl_impl (l, options, false /* step */, try_match); } } catch (const failed&) {} // Phase lock failure. @@ -1442,8 +1430,6 @@ namespace build2 true /* step */).second == target_state::failed) throw failed (); - // Note: only matched so no call to match_posthoc(). - if ((r = g.group_members (a)).members != nullptr) break; @@ -1457,13 +1443,6 @@ namespace build2 pair<bool, target_state> s ( match_impl_impl (l, 0 /* options */, true /* step */)); - if (s.second != target_state::failed && - g.has_group_prerequisites ()) // Already matched. - { - if (!match_posthoc (a, *l.target)) - s.second = target_state::failed; - } - if (s.second == target_state::failed) throw failed (); @@ -1576,9 +1555,9 @@ namespace build2 // Note: lock is a reference to avoid the stacking overhead. // void - resolve_group_impl (action a, const target& t, target_lock&& l) + resolve_group_impl (target_lock&& l) { - assert (a.inner ()); + assert (l.action.inner ()); pair<bool, target_state> r ( match_impl_impl (l, @@ -1586,15 +1565,6 @@ namespace build2 true /* step */, true /* try_match */)); - if (r.first && - r.second != target_state::failed && - l.offset == target::offset_applied && - t.has_group_prerequisites ()) // Already matched. - { - if (!match_posthoc (a, *l.target)) - r.second = target_state::failed; - } - l.unlock (); if (r.first && r.second == target_state::failed) diff --git a/libbuild2/algorithm.ixx b/libbuild2/algorithm.ixx index 51f7699..016eeed 100644 --- a/libbuild2/algorithm.ixx +++ b/libbuild2/algorithm.ixx @@ -664,7 +664,7 @@ namespace build2 } LIBBUILD2_SYMEXPORT void - resolve_group_impl (action, const target&, target_lock&&); + resolve_group_impl (target_lock&&); inline const target* resolve_group (action a, const target& t) @@ -684,7 +684,7 @@ namespace build2 // then unlock and return. // if (t.group == nullptr && l.offset < target::offset_tried) - resolve_group_impl (a, t, move (l)); + resolve_group_impl (move (l)); break; } |