From: Richard Geary Date: Sun, 11 Aug 2013 00:14:49 +0000 (-0400) Subject: Fix for missing "no work to do." message if all build edges are phony rules. X-Git-Tag: v1.4.0^2~17^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b78b27cba23e3bd2fce1cea4bf33a85eb645113d;p=platform%2Fupstream%2Fninja.git Fix for missing "no work to do." message if all build edges are phony rules. Added NestedPhonyPrintsDone unit test --- 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::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()); +}