summaryrefslogtreecommitdiffstats
path: root/src/clean.cc
diff options
context:
space:
mode:
authorEvan Martin <martine@danga.com>2012-10-29 16:53:30 (GMT)
committerEvan Martin <martine@danga.com>2012-10-31 19:34:07 (GMT)
commit93e509469953a90f31afc838536b82568da397b2 (patch)
treed009d6ce241e8b048648e74b19b383a9ad86bb12 /src/clean.cc
parent599d716fc78441436aebcde948886791d1988651 (diff)
downloadNinja-93e509469953a90f31afc838536b82568da397b2.zip
Ninja-93e509469953a90f31afc838536b82568da397b2.tar.gz
Ninja-93e509469953a90f31afc838536b82568da397b2.tar.bz2
refactor repeated code in cleaner
Diffstat (limited to 'src/clean.cc')
-rw-r--r--src/clean.cc28
1 files changed, 14 insertions, 14 deletions
diff --git a/src/clean.cc b/src/clean.cc
index c9d4cbd..0b8476b 100644
--- a/src/clean.cc
+++ b/src/clean.cc
@@ -82,6 +82,16 @@ bool Cleaner::IsAlreadyRemoved(const string& path) {
return (i != removed_.end());
}
+void Cleaner::RemoveEdgeFiles(Edge* edge) {
+ string depfile = edge->EvaluateDepFile();
+ if (!depfile.empty())
+ Remove(depfile);
+
+ string rspfile = edge->GetRspFile();
+ if (!rspfile.empty())
+ Remove(rspfile);
+}
+
void Cleaner::PrintHeader() {
if (config_.verbosity == BuildConfig::QUIET)
return;
@@ -113,12 +123,8 @@ int Cleaner::CleanAll(bool generator) {
out_node != (*e)->outputs_.end(); ++out_node) {
Remove((*out_node)->path());
}
- // Remove the depfile
- if (!(*e)->rule().depfile().empty())
- Remove((*e)->EvaluateDepFile());
- // Remove the response file
- if ((*e)->HasRspFile())
- Remove((*e)->GetRspFile());
+
+ RemoveEdgeFiles(*e);
}
PrintFooter();
return status_;
@@ -129,10 +135,7 @@ void Cleaner::DoCleanTarget(Node* target) {
// Do not try to remove phony targets
if (!e->is_phony()) {
Remove(target->path());
- if (!target->in_edge()->rule().depfile().empty())
- Remove(target->in_edge()->EvaluateDepFile());
- if (e->HasRspFile())
- Remove(e->GetRspFile());
+ RemoveEdgeFiles(e);
}
for (vector<Node*>::iterator n = e->inputs_.begin(); n != e->inputs_.end();
++n) {
@@ -200,10 +203,7 @@ void Cleaner::DoCleanRule(const Rule* rule) {
for (vector<Node*>::iterator out_node = (*e)->outputs_.begin();
out_node != (*e)->outputs_.end(); ++out_node) {
Remove((*out_node)->path());
- if (!(*e)->rule().depfile().empty())
- Remove((*e)->EvaluateDepFile());
- if ((*e)->HasRspFile())
- Remove((*e)->GetRspFile());
+ RemoveEdgeFiles(*e);
}
}
}