diff options
author | ikifof <ikifof@gmail.com> | 2018-04-28 01:34:55 (GMT) |
---|---|---|
committer | ikifof <ikifof@gmail.com> | 2019-05-25 18:14:43 (GMT) |
commit | 714621dba1b8b2d8cd6080b7bc82955b44054734 (patch) | |
tree | aaf2e1572decb72ba9cc9b00a909070fce0cfca9 /src/clean.cc | |
parent | 20b30dac6698d119e7797b34d6ed2c4ed8f48417 (diff) | |
download | Ninja-714621dba1b8b2d8cd6080b7bc82955b44054734.zip Ninja-714621dba1b8b2d8cd6080b7bc82955b44054734.tar.gz Ninja-714621dba1b8b2d8cd6080b7bc82955b44054734.tar.bz2 |
Adding a way to clean dead build artifacts that have an entry in the build log,
but are no longer produced by the current manifest. For now adding a dedicated
"-t cleandead" option, since it should be run after reading the log; ideally
it should be part of the build config and done before to start looking for
dirty targets so that an incremental build would produce the same end result
as a clean build from scratch. But since I am not 100% sure to understand the
comment in the NinjaMain::isPathDead(), I opted to make it a tool for now to
avoid impacting users who want to keep those files.
The option name "cleandead" was selected insteadof something like "reap" to
keep the "clean" prefix.
Diffstat (limited to 'src/clean.cc')
-rw-r--r-- | src/clean.cc | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/clean.cc b/src/clean.cc index d1f221d..ec6e7d7 100644 --- a/src/clean.cc +++ b/src/clean.cc @@ -124,6 +124,19 @@ int Cleaner::CleanAll(bool generator) { return status_; } +int Cleaner::CleanDead(const BuildLog::Entries& entries) { + Reset(); + PrintHeader(); + for (BuildLog::Entries::const_iterator i = entries.begin(); i != entries.end(); ++i) { + Node* n = state_->LookupNode(i->first); + if (!n || !n->in_edge()) { + Remove(i->first.AsString()); + } + } + PrintFooter(); + return status_; +} + void Cleaner::DoCleanTarget(Node* target) { if (Edge* e = target->in_edge()) { // Do not try to remove phony targets |