summaryrefslogtreecommitdiffstats
path: root/src/ninja.cc
diff options
context:
space:
mode:
authorNico Weber <nicolasweber@gmx.de>2014-01-02 04:31:34 (GMT)
committerNico Weber <nicolasweber@gmx.de>2014-01-02 04:31:34 (GMT)
commitb2e6fcf7031cfaf995c65820d14d4aa390daf9fb (patch)
treefebb947ed184e0bff21fa0556adc941c2dca4c82 /src/ninja.cc
parent38db96cba7886aeaec7f9af7f5f2eb960d3e1175 (diff)
downloadNinja-b2e6fcf7031cfaf995c65820d14d4aa390daf9fb.zip
Ninja-b2e6fcf7031cfaf995c65820d14d4aa390daf9fb.tar.gz
Ninja-b2e6fcf7031cfaf995c65820d14d4aa390daf9fb.tar.bz2
Remove dead entries in .ninja_log and .ninja_deps while recompacting.
For .ninja_deps, remove objects that have no in-edges or whose in-edges do not have a "deps" attribute. (This matches the behaviour of `-t deps`). BuildLog doesn't know about state, so let its recompact method take delegate that decides is a path is life or not, and implement it in NinjaMain.
Diffstat (limited to 'src/ninja.cc')
-rw-r--r--src/ninja.cc11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/ninja.cc b/src/ninja.cc
index a313ecb..298d993 100644
--- a/src/ninja.cc
+++ b/src/ninja.cc
@@ -68,7 +68,7 @@ struct Options {
/// The Ninja main() loads up a series of data structures; various tools need
/// to poke into these, so store them as fields on an object.
-struct NinjaMain {
+struct NinjaMain : public IsDead {
NinjaMain(const char* ninja_command, const BuildConfig& config) :
ninja_command_(ninja_command), config_(config) {}
@@ -137,6 +137,11 @@ struct NinjaMain {
/// Dump the output requested by '-d stats'.
void DumpMetrics();
+
+ virtual bool IsPathDead(StringPiece s) {
+ Node* n = state_.LookupNode(s);
+ return !n || !n->in_edge();
+ }
};
/// Subtools, accessible via "-t foo".
@@ -789,14 +794,14 @@ bool NinjaMain::OpenBuildLog(bool recompact_only) {
}
if (recompact_only) {
- bool success = build_log_.Recompact(log_path, &err);
+ bool success = build_log_.Recompact(log_path, this, &err);
if (!success)
Error("failed recompaction: %s", err.c_str());
return success;
}
if (!config_.dry_run) {
- if (!build_log_.OpenForWrite(log_path, &err)) {
+ if (!build_log_.OpenForWrite(log_path, this, &err)) {
Error("opening build log: %s", err.c_str());
return false;
}