summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEvan Martin <martine@danga.com>2011-12-06 16:26:39 (GMT)
committerEvan Martin <martine@danga.com>2011-12-06 16:26:39 (GMT)
commit0301500009f1e693004b1e1d17d680fc7a9ab224 (patch)
tree86c6fd13f959cf92dac0fc38348da18be46c58c2
parent19e0d398e1acc56fe6444cd1aedc5aef03fe73b5 (diff)
parent722953d14c16596bf4316d3c6eda18b3a17eb693 (diff)
downloadNinja-0301500009f1e693004b1e1d17d680fc7a9ab224.zip
Ninja-0301500009f1e693004b1e1d17d680fc7a9ab224.tar.gz
Ninja-0301500009f1e693004b1e1d17d680fc7a9ab224.tar.bz2
Merge pull request #152 from pcc/clean-depfiles
Have the clean tool remove depfiles
-rw-r--r--src/clean.cc2
-rw-r--r--src/clean_test.cc15
2 files changed, 17 insertions, 0 deletions
diff --git a/src/clean.cc b/src/clean.cc
index 033fa96..a89e1f5 100644
--- a/src/clean.cc
+++ b/src/clean.cc
@@ -111,6 +111,8 @@ int Cleaner::CleanAll(bool generator) {
out_node != (*e)->outputs_.end(); ++out_node) {
Remove((*out_node)->file_->path_);
}
+ if (!(*e)->rule_->depfile_.empty())
+ Remove((*e)->EvaluateDepFile());
}
PrintFooter();
return status_;
diff --git a/src/clean_test.cc b/src/clean_test.cc
index 8606239..9cd4a95 100644
--- a/src/clean_test.cc
+++ b/src/clean_test.cc
@@ -234,6 +234,21 @@ TEST_F(CleanTest, CleanRuleGenerator) {
EXPECT_EQ(2u, fs_.files_removed_.size());
}
+TEST_F(CleanTest, CleanDepFile) {
+ 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.CleanAll());
+ EXPECT_EQ(2, cleaner.cleaned_files_count());
+ EXPECT_EQ(2u, fs_.files_removed_.size());
+}
+
TEST_F(CleanTest, CleanFailure) {
ASSERT_NO_FATAL_FAILURE(AssertParse(&state_,
"build dir: cat src1\n"));