diff options
author | Evan Martin <martine@danga.com> | 2013-02-17 23:02:31 (GMT) |
---|---|---|
committer | Evan Martin <martine@danga.com> | 2013-04-05 17:10:29 (GMT) |
commit | 372a7a8850a6451dec4f4d2c556878064f2662fb (patch) | |
tree | bbf5d693c6f15422167aecfce3df3cc973ee7f36 /src | |
parent | 75381bcf071ed45af79c3515eb37f406065f9b58 (diff) | |
download | Ninja-372a7a8850a6451dec4f4d2c556878064f2662fb.zip Ninja-372a7a8850a6451dec4f4d2c556878064f2662fb.tar.gz Ninja-372a7a8850a6451dec4f4d2c556878064f2662fb.tar.bz2 |
refactor some of the output mtime-handling code
Reduces duplicated explain output.
Diffstat (limited to 'src')
-rw-r--r-- | src/graph.cc | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/src/graph.cc b/src/graph.cc index b000c48..0f99698 100644 --- a/src/graph.cc +++ b/src/graph.cc @@ -161,24 +161,25 @@ bool DependencyScan::RecomputeOutputDirty(Edge* edge, // Dirty if the output is older than the input. if (most_recent_input && output->mtime() < most_recent_input->mtime()) { + TimeStamp output_mtime = output->mtime(); + // If this is a restat rule, we may have cleaned the output with a restat // rule in a previous run and stored the most recent input mtime in the // build log. Use that mtime instead, so that the file will only be // considered dirty if an input was modified since the previous run. - TimeStamp most_recent_stamp = most_recent_input->mtime(); + bool used_restat = false; if (edge->GetBindingBool("restat") && build_log() && (entry = build_log()->LookupByOutput(output->path()))) { - if (entry->restat_mtime < most_recent_stamp) { - EXPLAIN("restat of output %s older than most recent input %s " - "(%d vs %d)", - output->path().c_str(), most_recent_input->path().c_str(), - entry->restat_mtime, most_recent_stamp); - return true; - } - } else { - EXPLAIN("output %s older than most recent input %s (%d vs %d)", - output->path().c_str(), most_recent_input->path().c_str(), - output->mtime(), most_recent_stamp); + output_mtime = entry->restat_mtime; + used_restat = true; + } + + if (output_mtime < most_recent_input->mtime()) { + EXPLAIN("%soutput %s older than most recent input %s " + "(%d vs %d)", + used_restat ? "restat of " : "", output->path().c_str(), + most_recent_input->path().c_str(), + output_mtime, most_recent_input->mtime()); return true; } } |