From: Qingning Huo Date: Tue, 6 Sep 2011 19:46:32 +0000 (+0100) Subject: Add depfile support to build command with multiple outputs (Fixes: #61) X-Git-Tag: release-120715~290^2~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8efe599247c762caa6da54a1c10e37c538319669;p=platform%2Fupstream%2Fninja.git Add depfile support to build command with multiple outputs (Fixes: #61) parsers.cpp: allow depfile used at build command with multiple outputs. graph.cpp: allow depfile used at build command with multiple outputs. parsers_test.cpp: make the test pass. As before, the depfile itself can only mention one target, which must be the first of a build command with multiple outpus. [There is really no need to mention all the output in the depfile, because all targets should depend on exactly the same files anyway, because these targets are built by a single build command.] --- diff --git a/src/graph.cc b/src/graph.cc index 9b5f10b..82716aa 100644 --- a/src/graph.cc +++ b/src/graph.cc @@ -150,10 +150,6 @@ bool Edge::LoadDepFile(State* state, DiskInterface* disk_interface, } // Check that this depfile matches our output. - if (outputs_.size() != 1) { - *err = "expected only one output"; - return false; - } if (outputs_[0]->file_->path_ != makefile.out_) { *err = "expected makefile to mention '" + outputs_[0]->file_->path_ + "', " "got '" + makefile.out_ + "'"; diff --git a/src/parsers.cc b/src/parsers.cc index 7f587a6..35790b2 100644 --- a/src/parsers.cc +++ b/src/parsers.cc @@ -471,13 +471,6 @@ bool ManifestParser::ParseEdge(string* err) { if (!rule) return tokenizer_.Error("unknown build rule '" + rule_name + "'", err); - if (!rule->depfile_.empty()) { - if (outs.size() > 1) { - return tokenizer_.Error("dependency files only work with single-output " - "rules", err); - } - } - for (;;) { string in; if (!tokenizer_.ReadIdent(&in)) diff --git a/src/parsers_test.cc b/src/parsers_test.cc index 1ac5990..12f09b0 100644 --- a/src/parsers_test.cc +++ b/src/parsers_test.cc @@ -316,11 +316,10 @@ TEST_F(ParserTest, Errors) { State state; ManifestParser parser(&state, NULL); string err; - EXPECT_FALSE(parser.Parse("rule cc\n command = foo\n depfile = bar\n" + EXPECT_TRUE(parser.Parse("rule cc\n command = foo\n depfile = bar\n" "build a.o b.o: cc c.cc\n", &err)); - EXPECT_EQ("line 4, col 16: dependency files only work with " - "single-output rules", err); + EXPECT_EQ("", err); } {