summaryrefslogtreecommitdiffstats
path: root/src
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
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')
-rw-r--r--src/build.cc2
-rw-r--r--src/graph.cc36
-rw-r--r--src/graph.h11
3 files changed, 23 insertions, 26 deletions
diff --git a/src/build.cc b/src/build.cc
index 45f6849..73dc1ff 100644
--- a/src/build.cc
+++ b/src/build.cc
@@ -426,7 +426,7 @@ void Plan::CleanNode(DependencyScan* scan, Node* node) {
bool dirty = false;
for (vector<Node*>::iterator ni = (*ei)->outputs_.begin();
!dirty && ni != (*ei)->outputs_.end(); ++ni) {
- dirty = scan->RecomputeOutputDirty(*ei, most_recent_input, 0,
+ dirty = scan->RecomputeOutputDirty(*ei, most_recent_input,
command, *ni);
}
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);
diff --git a/src/graph.h b/src/graph.h
index 428ba01..bd0cb34 100644
--- a/src/graph.h
+++ b/src/graph.h
@@ -192,10 +192,10 @@ struct ImplicitDepLoader {
DiskInterface* disk_interface)
: state_(state), disk_interface_(disk_interface), deps_log_(deps_log) {}
- /// Load implicit dependencies for \a edge. May fill in \a mtime with
- /// the timestamp of the loaded information.
- /// @return false on error (without filling \a err if info is just missing).
- bool LoadDeps(Edge* edge, TimeStamp* mtime, string* err);
+ /// Load implicit dependencies for \a edge.
+ /// @return false on error (without filling \a err if info is just missing
+ // or out of date).
+ bool LoadDeps(Edge* edge, string* err);
DepsLog* deps_log() const {
return deps_log_;
@@ -208,7 +208,7 @@ struct ImplicitDepLoader {
/// Load implicit dependencies for \a edge from the DepsLog.
/// @return false on error (without filling \a err if info is just missing).
- bool LoadDepsFromLog(Edge* edge, TimeStamp* mtime, string* err);
+ bool LoadDepsFromLog(Edge* edge, string* err);
/// Preallocate \a count spaces in the input array on \a edge, returning
/// an iterator pointing at the first new space.
@@ -243,7 +243,6 @@ struct DependencyScan {
/// Recompute whether a given single output should be marked dirty.
/// Returns true if so.
bool RecomputeOutputDirty(Edge* edge, Node* most_recent_input,
- TimeStamp deps_mtime,
const string& command, Node* output);
BuildLog* build_log() const {