diff options
author | Nico Weber <nicolasweber@gmx.de> | 2015-02-03 21:01:28 (GMT) |
---|---|---|
committer | Nico Weber <nicolasweber@gmx.de> | 2015-02-03 21:01:28 (GMT) |
commit | 636034b288777c9f0b7aca1072e0496de94db27c (patch) | |
tree | 164a28a3233e01581c958ba76c89627adc3419c6 | |
parent | 62458b6f19dd134d2a4a38ff81e368c8b7e5605d (diff) | |
parent | 5fbfa4ba72883cc0ecd199d17a70da3698be0402 (diff) | |
download | Ninja-636034b288777c9f0b7aca1072e0496de94db27c.zip Ninja-636034b288777c9f0b7aca1072e0496de94db27c.tar.gz Ninja-636034b288777c9f0b7aca1072e0496de94db27c.tar.bz2 |
Merge pull request #908 from colincross/multipass
Allow manifest rebuild to loop up to 100 times
-rw-r--r-- | src/ninja.cc | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/src/ninja.cc b/src/ninja.cc index 3e99782..48c7239 100644 --- a/src/ninja.cc +++ b/src/ninja.cc @@ -1061,9 +1061,9 @@ int real_main(int argc, char** argv) { return (ninja.*options.tool->func)(argc, argv); } - // The build can take up to 2 passes: one to rebuild the manifest, then - // another to build the desired target. - for (int cycle = 0; cycle < 2; ++cycle) { + // Limit number of rebuilds, to prevent infinite loops. + const int kCycleLimit = 100; + for (int cycle = 1; cycle <= kCycleLimit; ++cycle) { NinjaMain ninja(ninja_command, config); RealFileReader file_reader; @@ -1086,16 +1086,13 @@ int real_main(int argc, char** argv) { if (options.tool && options.tool->when == Tool::RUN_AFTER_LOGS) return (ninja.*options.tool->func)(argc, argv); - // The first time through, attempt to rebuild the manifest before - // building anything else. - if (cycle == 0) { - if (ninja.RebuildManifest(options.input_file, &err)) { - // Start the build over with the new manifest. - continue; - } else if (!err.empty()) { - Error("rebuilding '%s': %s", options.input_file, err.c_str()); - return 1; - } + // Attempt to rebuild the manifest before building anything else + if (ninja.RebuildManifest(options.input_file, &err)) { + // Start the build over with the new manifest. + continue; + } else if (!err.empty()) { + Error("rebuilding '%s': %s", options.input_file, err.c_str()); + return 1; } int result = ninja.RunBuild(argc, argv); @@ -1104,7 +1101,9 @@ int real_main(int argc, char** argv) { return result; } - return 1; // Shouldn't be reached. + Error("manifest '%s' still dirty after %d tries\n", + options.input_file, kCycleLimit); + return 1; } } // anonymous namespace |