diff options
author | Brad King <brad.king@kitware.com> | 2020-01-10 18:30:27 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2020-01-10 18:30:35 (GMT) |
commit | 2ee6baef4fdb2ace515b3c6032f3a1c35173aedc (patch) | |
tree | ca75e69c7c3245e9e7429febdec55ca3b742689b /Source/cmGlobalNinjaGenerator.cxx | |
parent | d76e4c147a9b0e7e9a6222c9192143b5559d1b23 (diff) | |
parent | fb18215904e8297a7a7cb449fc60bacf72cb89d0 (diff) | |
download | CMake-2ee6baef4fdb2ace515b3c6032f3a1c35173aedc.zip CMake-2ee6baef4fdb2ace515b3c6032f3a1c35173aedc.tar.gz CMake-2ee6baef4fdb2ace515b3c6032f3a1c35173aedc.tar.bz2 |
Merge topic 'ninja-postgen-commands'
fb18215904 Ninja: clean ninja metadata once generated
Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: Jan Niklas Hasse <jhasse@bixense.com>
Merge-request: !3316
Diffstat (limited to 'Source/cmGlobalNinjaGenerator.cxx')
-rw-r--r-- | Source/cmGlobalNinjaGenerator.cxx | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 4d43566..35b4f91 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -530,6 +530,35 @@ void cmGlobalNinjaGenerator::Generate() if (!this->WriteDefaultBuildFile()) { return; } + + auto run_ninja_tool = [this](char const* tool) { + std::vector<std::string> command; + command.push_back(this->NinjaCommand); + command.emplace_back("-t"); + command.emplace_back(tool); + std::string error; + if (!cmSystemTools::RunSingleCommand(command, nullptr, &error, nullptr, + nullptr, + cmSystemTools::OUTPUT_NONE)) { + this->GetCMakeInstance()->IssueMessage(MessageType::FATAL_ERROR, + "Running\n '" + + cmJoin(command, "' '") + + "'\n" + "failed with:\n " + + error); + cmSystemTools::SetFatalErrorOccured(); + } + }; + + if (this->NinjaSupportsCleanDeadTool) { + run_ninja_tool("cleandead"); + } + if (this->NinjaSupportsUnconditionalRecompactTool) { + run_ninja_tool("recompact"); + } + if (this->NinjaSupportsRestatTool) { + run_ninja_tool("restat"); + } } bool cmGlobalNinjaGenerator::FindMakeProgram(cmMakefile* mf) @@ -593,6 +622,16 @@ void cmGlobalNinjaGenerator::CheckNinjaFeatures() } } } + this->NinjaSupportsCleanDeadTool = !cmSystemTools::VersionCompare( + cmSystemTools::OP_LESS, this->NinjaVersion.c_str(), + RequiredNinjaVersionForCleanDeadTool().c_str()); + this->NinjaSupportsUnconditionalRecompactTool = + !cmSystemTools::VersionCompare( + cmSystemTools::OP_LESS, this->NinjaVersion.c_str(), + RequiredNinjaVersionForUnconditionalRecompactTool().c_str()); + this->NinjaSupportsRestatTool = !cmSystemTools::VersionCompare( + cmSystemTools::OP_LESS, this->NinjaVersion.c_str(), + RequiredNinjaVersionForRestatTool().c_str()); } bool cmGlobalNinjaGenerator::CheckLanguages( |