diff options
author | Peter Collingbourne <peter@pcc.me.uk> | 2011-09-18 02:28:44 (GMT) |
---|---|---|
committer | Peter Collingbourne <peter@pcc.me.uk> | 2011-10-24 00:16:24 (GMT) |
commit | 6fc220b8b98d0a89204f144557d935feb775aeca (patch) | |
tree | f61cf2a7b574f74cf1e4a7fd0d73003f8c3d4dd2 /src/graph.cc | |
parent | 5ff5891f5bed923b983c0f5a23c16d988d55f30e (diff) | |
download | Ninja-6fc220b8b98d0a89204f144557d935feb775aeca.zip Ninja-6fc220b8b98d0a89204f144557d935feb775aeca.tar.gz Ninja-6fc220b8b98d0a89204f144557d935feb775aeca.tar.bz2 |
Implement Make-style order-only dependencies
Previously, the implementation of order-only dependencies differed
between Make and Ninja in two important ways:
1) If the order-only dependency existed but was out of date, it
would never be rebuilt, whereas Make would always rebuild out of
date order-only dependencies.
2) If the order-only dependency did not exist, it would cause
its reverse dependencies to always build, whereas Make would only
rebuild a file if a non-order-only dependency was out of date.
A key distinction between Ninja and Make as seen through the above
two points was that in Ninja, order-only dependencies cared about
whether the target as a file exists (so perhaps a better name for
the old semantics would have been "missing-only dependencies").
These differences made it impossible to introduce an order-only
dependency on an always out-of-date (i.e. missing) target without
also causing the depender and its reverse dependencies to rebuild
unnecessarily on every build. Build systems which must perform some
action (such as logging the build start time, or printing a message)
at the start of every build typically implement this by adding to
every target an order-only dependency which performs this action,
which would have forced an entire rebuild on every invocation of
Ninja under the old semantics.
This commit causes Ninja to conform to the Make-style behaviour.
Diffstat (limited to 'src/graph.cc')
-rw-r--r-- | src/graph.cc | 25 |
1 files changed, 9 insertions, 16 deletions
diff --git a/src/graph.cc b/src/graph.cc index 65fed2e..9df6ecb 100644 --- a/src/graph.cc +++ b/src/graph.cc @@ -51,27 +51,20 @@ bool Edge::RecomputeDirty(State* state, DiskInterface* disk_interface, } } - if (is_order_only(i - inputs_.begin())) { - // Order-only deps only make us dirty if they're missing. - if (!(*i)->file_->exists()) { - dirty = true; - outputs_ready_ = false; - } - continue; - } - // If an input is not ready, neither are our outputs. if (Edge* edge = (*i)->in_edge_) if (!edge->outputs_ready_) outputs_ready_ = false; - // If a regular input is dirty (or missing), we're dirty. - // Otherwise consider mtime. - if ((*i)->dirty_) { - dirty = true; - } else { - if ((*i)->file_->mtime_ > most_recent_input) - most_recent_input = (*i)->file_->mtime_; + if (!is_order_only(i - inputs_.begin())) { + // If a regular input is dirty (or missing), we're dirty. + // Otherwise consider mtime. + if ((*i)->dirty_) { + dirty = true; + } else { + if ((*i)->file_->mtime_ > most_recent_input) + most_recent_input = (*i)->file_->mtime_; + } } } |