summaryrefslogtreecommitdiffstats
path: root/src/graph.cc
diff options
context:
space:
mode:
authorMaxim Kalaev <maximus.ka@gmail.com>2013-09-02 22:24:26 (GMT)
committerNico Weber <nicolasweber@gmx.de>2013-09-02 22:24:26 (GMT)
commitd7a46654a7be1a46a777a8d8a51f065ac98ce05d (patch)
treedddae66dc8b0a8358808493d4286b97e3f488a0d /src/graph.cc
parentddbf9a42b8a7a2d47e25f4af18f726d49f6f8a91 (diff)
downloadNinja-d7a46654a7be1a46a777a8d8a51f065ac98ce05d.zip
Ninja-d7a46654a7be1a46a777a8d8a51f065ac98ce05d.tar.gz
Ninja-d7a46654a7be1a46a777a8d8a51f065ac98ce05d.tar.bz2
Check depslog timestamp in LoadDepsFromLog(), not in RecomputeOutputDirty().
RecomputeOutputDirty() is called from two places: 1. RecomputeDirty(), which calls LoadDeps(). 2. CleanNode(), which always passes 0 for the deps mtime. So this is no behavior change in either case. deps_mtime was nonzero only in deps mode, and it got passed all over the place. This makes things simpler.
Diffstat (limited to 'src/graph.cc')
-rw-r--r--src/graph.cc36
1 files changed, 17 insertions, 19 deletions
diff --git a/src/graph.cc b/src/graph.cc
index fdd93de..b58e17f 100644
--- a/src/graph.cc
+++ b/src/graph.cc
@@ -61,8 +61,7 @@ bool DependencyScan::RecomputeDirty(Edge* edge, string* err) {
bool dirty = false;
edge->outputs_ready_ = true;
- TimeStamp deps_mtime = 0;
- if (!dep_loader_.LoadDeps(edge, &deps_mtime, err)) {
+ if (!dep_loader_.LoadDeps(edge, err)) {
if (!err->empty())
return false;
// Failed to load dependency info: rebuild to regenerate it.
@@ -113,8 +112,7 @@ bool DependencyScan::RecomputeDirty(Edge* edge, string* err) {
for (vector<Node*>::iterator i = edge->outputs_.begin();
i != edge->outputs_.end(); ++i) {
(*i)->StatIfNecessary(disk_interface_);
- if (RecomputeOutputDirty(edge, most_recent_input, deps_mtime,
- command, *i)) {
+ if (RecomputeOutputDirty(edge, most_recent_input, command, *i)) {
dirty = true;
break;
}
@@ -143,7 +141,6 @@ bool DependencyScan::RecomputeDirty(Edge* edge, string* err) {
bool DependencyScan::RecomputeOutputDirty(Edge* edge,
Node* most_recent_input,
- TimeStamp deps_mtime,
const string& command,
Node* output) {
if (edge->is_phony()) {
@@ -185,13 +182,6 @@ bool DependencyScan::RecomputeOutputDirty(Edge* edge,
}
}
- // Dirty if the output is newer than the deps.
- if (deps_mtime && output->mtime() > deps_mtime) {
- EXPLAIN("stored deps info out of date for for %s (%d vs %d)",
- output->path().c_str(), deps_mtime, output->mtime());
- return true;
- }
-
// May also be dirty due to the command changing since the last build.
// But if this is a generator rule, the command changing does not make us
// dirty.
@@ -332,10 +322,10 @@ void Node::Dump(const char* prefix) const {
}
}
-bool ImplicitDepLoader::LoadDeps(Edge* edge, TimeStamp* mtime, string* err) {
+bool ImplicitDepLoader::LoadDeps(Edge* edge, string* err) {
string deps_type = edge->GetBinding("deps");
if (!deps_type.empty()) {
- if (!LoadDepsFromLog(edge, mtime, err)) {
+ if (!LoadDepsFromLog(edge, err)) {
if (!err->empty())
return false;
EXPLAIN("deps for %s are missing", edge->outputs_[0]->path().c_str());
@@ -406,13 +396,21 @@ bool ImplicitDepLoader::LoadDepFile(Edge* edge, const string& path,
return true;
}
-bool ImplicitDepLoader::LoadDepsFromLog(Edge* edge, TimeStamp* deps_mtime,
- string* err) {
- DepsLog::Deps* deps = deps_log_->GetDeps(edge->outputs_[0]);
- if (!deps)
+bool ImplicitDepLoader::LoadDepsFromLog(Edge* edge, string* err) {
+ // NOTE: deps are only supported for single-target edges.
+ Node* output = edge->outputs_[0];
+ DepsLog::Deps* deps = deps_log_->GetDeps(output);
+ if (!deps) {
+ EXPLAIN("deps for '%s' are missing", output->path().c_str());
return false;
+ }
- *deps_mtime = deps->mtime;
+ // Deps are invalid if the output is newer than the deps.
+ if (output->mtime() > deps->mtime) {
+ EXPLAIN("stored deps info out of date for for '%s' (%d vs %d)",
+ output->path().c_str(), deps->mtime, output->mtime());
+ return false;
+ }
vector<Node*>::iterator implicit_dep =
PreallocateSpace(edge, deps->node_count);