From 57d8557ff3bfe6772f2dbada1d1ffa5d378ca763 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Fri, 25 Nov 2011 15:18:03 +0000 Subject: Factor out Edge::EvaluateDepFile --- src/graph.cc | 9 ++++++--- src/graph.h | 1 + 2 files changed, 7 insertions(+), 3 deletions(-) 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); -- cgit v0.12 From 1b471c1c4251dc05c2d5b71dd5d1d335c7827a9b Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Sun, 4 Dec 2011 02:51:30 +0000 Subject: Use the modification time of the depfile when computing restat_mtime Fixes issue #144. --- src/build.cc | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) 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::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()); -- cgit v0.12