diff options
Diffstat (limited to 'src/build_log.cc')
-rw-r--r-- | src/build_log.cc | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/build_log.cc b/src/build_log.cc index b92a06f..3f24c16 100644 --- a/src/build_log.cc +++ b/src/build_log.cc @@ -108,9 +108,10 @@ BuildLog::~BuildLog() { Close(); } -bool BuildLog::OpenForWrite(const string& path, string* err) { +bool BuildLog::OpenForWrite(const string& path, const BuildLogUser& user, + string* err) { if (needs_recompaction_) { - if (!Recompact(path, err)) + if (!Recompact(path, user, err)) return false; } @@ -350,7 +351,8 @@ bool BuildLog::WriteEntry(FILE* f, const LogEntry& entry) { entry.output.c_str(), entry.command_hash) > 0; } -bool BuildLog::Recompact(const string& path, string* err) { +bool BuildLog::Recompact(const string& path, const BuildLogUser& user, + string* err) { METRIC_RECORD(".ninja_log recompact"); printf("Recompacting log...\n"); @@ -368,7 +370,13 @@ bool BuildLog::Recompact(const string& path, string* err) { return false; } + vector<StringPiece> dead_outputs; for (Entries::iterator i = entries_.begin(); i != entries_.end(); ++i) { + if (user.IsPathDead(i->first)) { + dead_outputs.push_back(i->first); + continue; + } + if (!WriteEntry(f, *i->second)) { *err = strerror(errno); fclose(f); @@ -376,6 +384,9 @@ bool BuildLog::Recompact(const string& path, string* err) { } } + for (size_t i = 0; i < dead_outputs.size(); ++i) + entries_.erase(dead_outputs[i]); + fclose(f); if (unlink(path.c_str()) < 0) { *err = strerror(errno); |