diff options
-rw-r--r-- | src/build.cc | 5 | ||||
-rw-r--r-- | src/build.h | 2 | ||||
-rw-r--r-- | src/graph_test.cc | 20 |
3 files changed, 25 insertions, 2 deletions
diff --git a/src/build.cc b/src/build.cc index 45f6849..6d23f3b 100644 --- a/src/build.cc +++ b/src/build.cc @@ -362,8 +362,11 @@ void Plan::ResumeDelayedJobs(Edge* edge) { void Plan::EdgeFinished(Edge* edge) { map<Edge*, bool>::iterator i = want_.find(edge); assert(i != want_.end()); - if (i->second) + if (i->second) { --wanted_edges_; + if (!edge->is_phony()) + --command_edges_; + } want_.erase(i); edge->outputs_ready_ = true; diff --git a/src/build.h b/src/build.h index 33df7d0..a872f6c 100644 --- a/src/build.h +++ b/src/build.h @@ -51,7 +51,7 @@ struct Plan { Edge* FindWork(); /// Returns true if there's more work to be done. - bool more_to_do() const { return wanted_edges_; } + bool more_to_do() const { return (command_edges_ > 0); } /// Dumps the current state of the plan. void Dump(); diff --git a/src/graph_test.cc b/src/graph_test.cc index 63d5757..8521216 100644 --- a/src/graph_test.cc +++ b/src/graph_test.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "graph.h" +#include "build.h" #include "test.h" @@ -226,3 +227,22 @@ TEST_F(GraphTest, DepfileOverrideParent) { Edge* edge = GetNode("out")->in_edge(); EXPECT_EQ("depfile is y", edge->GetBinding("command")); } + +// Verify that building a nested phony rule prints "no work to do" +TEST_F(GraphTest, NestedPhonyPrintsDone) { + AssertParse(&state_, +"build n1: phony \n" +"build n2: phony n1\n" + ); + string err; + Edge* edge = GetNode("n2")->in_edge(); + EXPECT_TRUE(scan_.RecomputeDirty(edge, &err)); + ASSERT_EQ("", err); + + Plan plan_; + EXPECT_TRUE(plan_.AddTarget(GetNode("n2"), &err)); + ASSERT_EQ("", err); + + EXPECT_EQ(0, plan_.command_edge_count()); + ASSERT_FALSE(plan_.more_to_do()); +} |