summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEvan Martin <martine@danga.com>2011-12-06 16:25:59 (GMT)
committerEvan Martin <martine@danga.com>2011-12-06 16:25:59 (GMT)
commit19e0d398e1acc56fe6444cd1aedc5aef03fe73b5 (patch)
treeb409050a0240eca0949edb8a2bdcd8b7eadc110f
parentf570d499dc7b281eaae3436a5292e55b808d2ed7 (diff)
parent1b471c1c4251dc05c2d5b71dd5d1d335c7827a9b (diff)
downloadNinja-19e0d398e1acc56fe6444cd1aedc5aef03fe73b5.zip
Ninja-19e0d398e1acc56fe6444cd1aedc5aef03fe73b5.tar.gz
Ninja-19e0d398e1acc56fe6444cd1aedc5aef03fe73b5.tar.bz2
Merge pull request #151 from pcc/restat-depfiles
Use the modification time of the depfile when computing restat_mtime
-rw-r--r--src/build.cc10
-rw-r--r--src/graph.cc9
-rw-r--r--src/graph.h1
3 files changed, 16 insertions, 4 deletions
diff --git a/src/build.cc b/src/build.cc
index bb73f7d..f3d7d9b 100644
--- a/src/build.cc
+++ b/src/build.cc
@@ -593,7 +593,7 @@ void Builder::FinishEdge(Edge* edge, bool success, const string& output) {
if (node_cleaned) {
// If any output was cleaned, find the most recent mtime of any
- // (existing) non-order-only input.
+ // (existing) non-order-only input or the depfile.
for (vector<Node*>::iterator i = edge->inputs_.begin();
i != edge->inputs_.end() - edge->order_only_deps_; ++i) {
time_t input_mtime = disk_interface_->Stat((*i)->file_->path_);
@@ -605,6 +605,14 @@ void Builder::FinishEdge(Edge* edge, bool success, const string& output) {
restat_mtime = input_mtime;
}
+ if (restat_mtime != 0 && !edge->rule_->depfile_.empty()) {
+ time_t depfile_mtime = disk_interface_->Stat(edge->EvaluateDepFile());
+ if (depfile_mtime == 0)
+ restat_mtime = 0;
+ else if (depfile_mtime > restat_mtime)
+ restat_mtime = depfile_mtime;
+ }
+
// The total number of edges in the plan may have changed as a result
// of a restat.
status_->PlanHasTotalEdges(plan_.command_edge_count());
diff --git a/src/graph.cc b/src/graph.cc
index d881280..424f941 100644
--- a/src/graph.cc
+++ b/src/graph.cc
@@ -177,6 +177,11 @@ string Edge::EvaluateCommand() {
return rule_->command_.Evaluate(&env);
}
+string Edge::EvaluateDepFile() {
+ EdgeEnv env(this);
+ return rule_->depfile_.Evaluate(&env);
+}
+
string Edge::GetDescription() {
EdgeEnv env(this);
return rule_->description_.Evaluate(&env);
@@ -184,9 +189,7 @@ string Edge::GetDescription() {
bool Edge::LoadDepFile(State* state, DiskInterface* disk_interface,
string* err) {
- EdgeEnv env(this);
- string path = rule_->depfile_.Evaluate(&env);
-
+ string path = EvaluateDepFile();
string content = disk_interface->ReadFile(path, err);
if (!err->empty())
return false;
diff --git a/src/graph.h b/src/graph.h
index 9080dcc..67f7b10 100644
--- a/src/graph.h
+++ b/src/graph.h
@@ -92,6 +92,7 @@ struct Edge {
const string& command, Node* output);
string EvaluateCommand(); // XXX move to env, take env ptr
+ string EvaluateDepFile();
string GetDescription();
bool LoadDepFile(State* state, DiskInterface* disk_interface, string* err);