diff options
author | Nico Weber <nicolasweber@gmx.de> | 2015-03-17 01:21:15 (GMT) |
---|---|---|
committer | Nico Weber <nicolasweber@gmx.de> | 2015-03-17 01:21:15 (GMT) |
commit | 717619a260633ca0e7c9eb2366130fc06ebacfff (patch) | |
tree | 98394c40861c61c7c2ff9d535728c72b35e1b7e0 /src | |
parent | d5746fdd1754cbd539ab3ca7a58c7b75502ed4c4 (diff) | |
parent | 157a71f39b19d4fac43c814211c2093de205adab (diff) | |
download | Ninja-717619a260633ca0e7c9eb2366130fc06ebacfff.zip Ninja-717619a260633ca0e7c9eb2366130fc06ebacfff.tar.gz Ninja-717619a260633ca0e7c9eb2366130fc06ebacfff.tar.bz2 |
Merge pull request #930 from nico/depcolon
On unexpected output in a .d file, rebuild instead erroring.
Diffstat (limited to 'src')
-rw-r--r-- | src/build_test.cc | 20 | ||||
-rw-r--r-- | src/depfile_parser.cc | 4 | ||||
-rw-r--r-- | src/depfile_parser.in.cc | 4 | ||||
-rw-r--r-- | src/depfile_parser_test.cc | 2 | ||||
-rw-r--r-- | src/graph.cc | 7 |
5 files changed, 31 insertions, 6 deletions
diff --git a/src/build_test.cc b/src/build_test.cc index bd1cd30..65d189d 100644 --- a/src/build_test.cc +++ b/src/build_test.cc @@ -816,8 +816,7 @@ TEST_F(BuildTest, DepFileParseError) { fs_.Create("foo.c", ""); fs_.Create("foo.o.d", "randomtext\n"); EXPECT_FALSE(builder_.AddTarget("foo.o", &err)); - EXPECT_EQ("expected depfile 'foo.o.d' to mention 'foo.o', got 'randomtext'", - err); + EXPECT_EQ("foo.o.d: expected ':' in depfile", err); } TEST_F(BuildTest, OrderOnlyDeps) { @@ -2043,6 +2042,23 @@ TEST_F(BuildWithDepsLogTest, RestatMissingDepfileDepslog) { ASSERT_EQ(0u, command_runner_.commands_ran_.size()); } +TEST_F(BuildTest, WrongOutputInDepfileCausesRebuild) { + string err; + const char* manifest = +"rule cc\n" +" command = cc $in\n" +" depfile = $out.d\n" +"build foo.o: cc foo.c\n"; + + fs_.Create("foo.c", ""); + fs_.Create("foo.o", ""); + fs_.Create("header.h", ""); + fs_.Create("foo.o.d", "bar.o.d: header.h\n"); + + RebuildTarget("foo.o", manifest, "build_log", "ninja_deps"); + ASSERT_EQ(1u, command_runner_.commands_ran_.size()); +} + TEST_F(BuildTest, Console) { ASSERT_NO_FATAL_FAILURE(AssertParse(&state_, "rule console\n" diff --git a/src/depfile_parser.cc b/src/depfile_parser.cc index 4ca3943..7268f31 100644 --- a/src/depfile_parser.cc +++ b/src/depfile_parser.cc @@ -230,5 +230,9 @@ yy16: return false; } } + if (parsing_targets) { + *err = "expected ':' in depfile"; + return false; + } return true; } diff --git a/src/depfile_parser.in.cc b/src/depfile_parser.in.cc index b59baf0..deaee5b 100644 --- a/src/depfile_parser.in.cc +++ b/src/depfile_parser.in.cc @@ -112,5 +112,9 @@ bool DepfileParser::Parse(string* content, string* err) { return false; } } + if (parsing_targets) { + *err = "expected ':' in depfile"; + return false; + } return true; } diff --git a/src/depfile_parser_test.cc b/src/depfile_parser_test.cc index e67ef79..8b57a1e 100644 --- a/src/depfile_parser_test.cc +++ b/src/depfile_parser_test.cc @@ -106,7 +106,7 @@ TEST_F(DepfileParserTest, Escapes) { // it through. string err; EXPECT_TRUE(Parse( -"\\!\\@\\#$$\\%\\^\\&\\\\", +"\\!\\@\\#$$\\%\\^\\&\\\\:", &err)); ASSERT_EQ("", err); EXPECT_EQ("\\!\\@#$\\%\\^\\&\\", diff --git a/src/graph.cc b/src/graph.cc index cbf7921..76c4e9a 100644 --- a/src/graph.cc +++ b/src/graph.cc @@ -390,12 +390,13 @@ bool ImplicitDepLoader::LoadDepFile(Edge* edge, const string& path, &depfile.out_.len_, &unused, err)) return false; - // Check that this depfile matches the edge's output. + // Check that this depfile matches the edge's output, if not return false to + // mark the edge as dirty. Node* first_output = edge->outputs_[0]; StringPiece opath = StringPiece(first_output->path()); if (opath != depfile.out_) { - *err = "expected depfile '" + path + "' to mention '" + - first_output->path() + "', got '" + depfile.out_.AsString() + "'"; + EXPLAIN("expected depfile '%s' to mention '%s', got '%s'", path.c_str(), + first_output->path().c_str(), depfile.out_.AsString().c_str()); return false; } |