always use output timestamp for deps
authorEvan Martin <martine@danga.com>
Wed, 10 Apr 2013 19:49:23 +0000 (12:49 -0700)
committerEvan Martin <martine@danga.com>
Wed, 10 Apr 2013 19:49:23 +0000 (12:49 -0700)
Using the timestamp of the .d file was wrong.  It can be written
at a different time than the output, and it is immediately deleted
after parsing; only the output remains for subsequent timestamp
comparison purposes, so always use the output's timestamp.  (This
is how the code worked on Windows already.)

src/build.cc
src/build.h

index 39e3e2a..199749f 100644 (file)
@@ -714,12 +714,10 @@ void Builder::FinishCommand(CommandRunner::Result* result) {
   // can fail, which makes the command fail from a build perspective.
 
   vector<Node*> deps_nodes;
-  TimeStamp deps_mtime = 0;
   string deps_type = edge->GetBinding("deps");
   if (result->success() && !deps_type.empty()) {
     string extract_err;
-    if (!ExtractDeps(result, deps_type, &deps_nodes, &deps_mtime,
-                     &extract_err)) {
+    if (!ExtractDeps(result, deps_type, &deps_nodes, &extract_err)) {
       if (!result->output.empty())
         result->output.append("\n");
       result->output.append(extract_err);
@@ -790,11 +788,7 @@ void Builder::FinishCommand(CommandRunner::Result* result) {
   if (!deps_type.empty()) {
     assert(edge->outputs_.size() == 1 && "should have been rejected by parser");
     Node* out = edge->outputs_[0];
-    if (!deps_mtime) {
-      // On Windows there's no separate file to compare against; just reuse
-      // the output's mtime.
-      deps_mtime = disk_interface_->Stat(out->path());
-    }
+    TimeStamp deps_mtime = disk_interface_->Stat(out->path());
     scan_.deps_log()->RecordDeps(out, deps_mtime, deps_nodes);
   }
 
@@ -803,7 +797,6 @@ void Builder::FinishCommand(CommandRunner::Result* result) {
 bool Builder::ExtractDeps(CommandRunner::Result* result,
                           const string& deps_type,
                           vector<Node*>* deps_nodes,
-                          TimeStamp* deps_mtime,
                           string* err) {
 #ifdef _WIN32
   if (deps_type == "msvc") {
@@ -822,12 +815,6 @@ bool Builder::ExtractDeps(CommandRunner::Result* result,
       return false;
     }
 
-    *deps_mtime = disk_interface_->Stat(depfile);
-    if (*deps_mtime <= 0) {
-      *err = string("unable to read depfile");
-      return false;
-    }
-
     string content = disk_interface_->ReadFile(depfile, err);
     if (!err->empty())
       return false;
index ca75ade..5cbd2a6 100644 (file)
@@ -178,8 +178,7 @@ struct Builder {
 
  private:
   bool ExtractDeps(CommandRunner::Result* result, const string& deps_type,
-                   vector<Node*>* deps_nodes, TimeStamp* deps_mtime,
-                   string* err);
+                   vector<Node*>* deps_nodes, string* err);
 
   DiskInterface* disk_interface_;
   DependencyScan scan_;