diff options
author | Brad King <brad.king@kitware.com> | 2020-01-27 18:22:15 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2020-01-27 20:09:18 (GMT) |
commit | 5d92e60d81157a6cece044313d52cbe76b55ceed (patch) | |
tree | c1b198d22437fbc848cef20417777dc29d5bc0ec | |
parent | dd0a4718fd72d2d7797911d7e3544584ad4268ad (diff) | |
download | CMake-5d92e60d81157a6cece044313d52cbe76b55ceed.zip CMake-5d92e60d81157a6cece044313d52cbe76b55ceed.tar.gz CMake-5d92e60d81157a6cece044313d52cbe76b55ceed.tar.bz2 |
Ninja: Skip cleandead and recompact if build.ninja is missing
In error cases the `build.ninja` file may not exist. Skip running ninja
tools that require it so that we do not generate additional errors.
-rw-r--r-- | Source/cmGlobalNinjaGenerator.cxx | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 22c0e13..c1ca2f8 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -553,18 +553,26 @@ void cmGlobalNinjaGenerator::Generate() bool const expectBuildManifest = !this->IsMultiConfig() && this->OutputPathPrefix.empty(); + // Skip some ninja tools if they need 'build.ninja' but it is missing. + bool const missingBuildManifest = expectBuildManifest && + (this->NinjaSupportsCleanDeadTool || + this->NinjaSupportsUnconditionalRecompactTool) && + !cmSystemTools::FileExists("build.ninja"); + // The `cleandead` tool needs to know about all outputs in the build we just // wrote out. Ninja-Multi doesn't have a single `build.ninja` we can use that // is the union of all generated configurations, so we can't run it reliably // in that case. - if (this->NinjaSupportsCleanDeadTool && expectBuildManifest) { + if (this->NinjaSupportsCleanDeadTool && expectBuildManifest && + !missingBuildManifest) { run_ninja_tool({ "cleandead" }); } // The `recompact` tool loads the manifest. As above, we don't have a single // `build.ninja` to load for this in Ninja-Multi. This may be relaxed in the // future pending further investigation into how Ninja works upstream // (ninja#1721). - if (this->NinjaSupportsUnconditionalRecompactTool && expectBuildManifest) { + if (this->NinjaSupportsUnconditionalRecompactTool && expectBuildManifest && + !missingBuildManifest) { run_ninja_tool({ "recompact" }); } if (this->NinjaSupportsRestatTool && this->OutputPathPrefix.empty()) { |