do not delete files from the logs that still exist on disk
authorNico Weber <nicolasweber@gmx.de>
Thu, 19 Jun 2014 23:09:50 +0000 (16:09 -0700)
committerNico Weber <nicolasweber@gmx.de>
Fri, 20 Jun 2014 14:24:23 +0000 (07:24 -0700)
This is to keep the possibility of maybe having a tool that deletes
old files in the future, or for having a tool which exposes this
information to generators so they can do that.

See https://github.com/martine/ninja/pull/697#issuecomment-37140762
and the discussion on #762.

Idea from @maximuska!

src/ninja.cc

index e555df4..15e265b 100644 (file)
@@ -147,7 +147,9 @@ struct NinjaMain : public BuildLogUser {
     // edge is rare, and the first recompaction will delete all old outputs from
     // the deps log, and then a second recompaction will clear the build log,
     // which seems good enough for this corner case.)
-    return !n || !n->in_edge();
+    // Do keep entries around for files which still exist on disk, for
+    // generators that want to use this information.
+    return (!n || !n->in_edge()) && disk_interface_.Stat(s.AsString()) == 0;
   }
 };