summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEvan Martin <martine@danga.com>2012-04-11 00:07:42 (GMT)
committerEvan Martin <martine@danga.com>2012-04-11 00:07:42 (GMT)
commit16cab01cccf0b3ccadb150cd54f760929b3cc07e (patch)
treee48717680d84bfaa778be1d6b5d67909543b2568 /src
parent39bf6c94701d089f70b761ce8247356df751203d (diff)
parentef505e4573b14c802b1e5c2891694fa3c4e677e1 (diff)
downloadNinja-16cab01cccf0b3ccadb150cd54f760929b3cc07e.zip
Ninja-16cab01cccf0b3ccadb150cd54f760929b3cc07e.tar.gz
Ninja-16cab01cccf0b3ccadb150cd54f760929b3cc07e.tar.bz2
Merge pull request #252 from qhuo/remove-depfile-when-cleaning
Remove depfiles when running "ninja -t clean <target>" or "ninja -t clean -r <rule>"
Diffstat (limited to 'src')
-rw-r--r--src/clean.cc4
-rw-r--r--src/clean_test.cc30
2 files changed, 34 insertions, 0 deletions
diff --git a/src/clean.cc b/src/clean.cc
index e09ab4e..c6a294f 100644
--- a/src/clean.cc
+++ b/src/clean.cc
@@ -125,6 +125,8 @@ int Cleaner::CleanAll(bool generator) {
void Cleaner::DoCleanTarget(Node* target) {
if (target->in_edge()) {
Remove(target->path());
+ if (!target->in_edge()->rule().depfile().empty())
+ Remove(target->in_edge()->EvaluateDepFile());
if (target->in_edge()->HasRspFile())
Remove(target->in_edge()->GetRspFile());
for (vector<Node*>::iterator n = target->in_edge()->inputs_.begin();
@@ -187,6 +189,8 @@ 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());
}
diff --git a/src/clean_test.cc b/src/clean_test.cc
index fbbe6a1..2e3a6b0 100644
--- a/src/clean_test.cc
+++ b/src/clean_test.cc
@@ -249,6 +249,36 @@ TEST_F(CleanTest, CleanDepFile) {
EXPECT_EQ(2u, fs_.files_removed_.size());
}
+TEST_F(CleanTest, CleanDepFileOnCleanTarget) {
+ ASSERT_NO_FATAL_FAILURE(AssertParse(&state_,
+"rule cc\n"
+" command = cc $in > $out\n"
+" depfile = $out.d\n"
+"build out1: cc in1\n"));
+ fs_.Create("out1", 1, "");
+ fs_.Create("out1.d", 1, "");
+
+ Cleaner cleaner(&state_, config_, &fs_);
+ EXPECT_EQ(0, cleaner.CleanTarget("out1"));
+ EXPECT_EQ(2, cleaner.cleaned_files_count());
+ EXPECT_EQ(2u, fs_.files_removed_.size());
+}
+
+TEST_F(CleanTest, CleanDepFileOnCleanRule) {
+ ASSERT_NO_FATAL_FAILURE(AssertParse(&state_,
+"rule cc\n"
+" command = cc $in > $out\n"
+" depfile = $out.d\n"
+"build out1: cc in1\n"));
+ fs_.Create("out1", 1, "");
+ fs_.Create("out1.d", 1, "");
+
+ Cleaner cleaner(&state_, config_, &fs_);
+ EXPECT_EQ(0, cleaner.CleanRule("cc"));
+ EXPECT_EQ(2, cleaner.cleaned_files_count());
+ EXPECT_EQ(2u, fs_.files_removed_.size());
+}
+
TEST_F(CleanTest, CleanRspFile) {
ASSERT_NO_FATAL_FAILURE(AssertParse(&state_,
"rule cc\n"