Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

make it more explicit that a bad build log causes us to rebuild

(Committing this on top of b56fe80 since they're related,
but I may end up reverting both.)
  • Loading branch information...
commit 697350d1220f50c32043875b49c71c8a294098a4 1 parent 413103c
@martine authored
Showing with 12 additions and 4 deletions.
  1. +6 −3 src/build_log.cc
  2. +1 −1  src/build_log_test.cc
  3. +5 −0 src/ninja.cc
View
9 src/build_log.cc
@@ -235,10 +235,13 @@ bool BuildLog::Load(const string& path, string* err) {
sscanf(line_start, kFileSignature, &log_version);
if (log_version < kOldestSupportedVersion) {
- *err = "unable to extract version from build log, perhaps due to "
- "being too old; you must clobber your build output and rebuild";
+ *err = ("build log version invalid, perhaps due to being too old; "
+ "starting over");
fclose(file);
- return false;
+ unlink(path.c_str());
+ // Don't report this as a failure. An empty build log will cause
+ // us to rebuild the outputs anyway.
+ return true;
}
}
View
2  src/build_log_test.cc
@@ -154,7 +154,7 @@ TEST_F(BuildLogTest, ObsoleteOldVersion) {
string err;
BuildLog log;
- EXPECT_FALSE(log.Load(kTestFilename, &err));
+ EXPECT_TRUE(log.Load(kTestFilename, &err));
ASSERT_NE(err.find("version"), string::npos);
}
View
5 src/ninja.cc
@@ -759,6 +759,11 @@ int NinjaMain(int argc, char** argv) {
Error("loading build log %s: %s", log_path.c_str(), err.c_str());
return 1;
}
+ if (!err.empty()) {
+ // Hack: Load() can return a warning via err by returning true.
+ Warning("%s", err.c_str());
+ err.clear();
+ }
if (!build_log.OpenForWrite(log_path, &err)) {
Error("opening build log: %s", err.c_str());

1 comment on commit 697350d

@buildhive

Evan Martin » ninja #137 FAILURE
Looks like this commit caused a build failure
(what's this?)

Please sign in to comment.
Something went wrong with that request. Please try again.