aboutsummaryrefslogtreecommitdiff
path: root/build2/target.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2017-09-01 17:33:44 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2017-09-01 17:33:44 +0200
commit53105890d75789c81adbb3d781eff9ebd7110222 (patch)
treeda93174356fc2d0a80f49b11e0cd16e7c71b7c80 /build2/target.cxx
parent631c76d7613458dbef208ca056e194e94a5becf3 (diff)
Add support for try_match(), use to handle deleted headers
Diffstat (limited to 'build2/target.cxx')
-rw-r--r--build2/target.cxx23
1 files changed, 15 insertions, 8 deletions
diff --git a/build2/target.cxx b/build2/target.cxx
index 40c73c0..7ff995d 100644
--- a/build2/target.cxx
+++ b/build2/target.cxx
@@ -117,7 +117,7 @@ namespace build2
return *r;
}
- target_state target::
+ pair<bool, target_state> target::
state (action_type a) const
{
assert (phase == run_phase::match);
@@ -147,15 +147,15 @@ namespace build2
for (; e == lock; e = task_count.load (memory_order_acquire))
this_thread::yield ();
- if (e >= busy)
- return target_state::unchanged; // Override in progress.
+ if (e >= busy) // Override in progress.
+ return make_pair (true, target_state::unchanged);
// Unlike lock_impl(), we are only called after being matched for this
// action so if we see executed, then it means executed for this action
// (or noop).
//
if (e == exec)
- return group_state () ? group->state_ : state_;
+ return make_pair (true, group_state () ? group->state_ : state_);
// Try to grab the spin-lock.
//
@@ -174,17 +174,24 @@ namespace build2
// We have the spin-lock. Quickly get the matched action and unlock.
//
action_type ma (action);
- bool failed (state_ == target_state::failed);
+ bool mf (state_ == target_state::failed);
task_count.store (e, memory_order_release);
if (ma > a) // Overriden.
- return failed ? target_state::failed: target_state::unchanged;
+ return make_pair (true, // Override may have failed but we had the rule.
+ mf ? target_state::failed: target_state::unchanged);
// Otherwise we should have a matched target.
//
- assert (ma == a && (e == b + target::offset_applied || e == exec));
+ assert (ma == a);
- return group_state () ? group->state_ : state_;
+ if (e == b + target::offset_tried)
+ return make_pair (false, target_state::unknown);
+ else
+ {
+ assert (e == b + target::offset_applied || e == exec);
+ return make_pair (true, group_state () ? group->state_ : state_);
+ }
}
pair<lookup, size_t> target::