|
@@ -7,11 +7,11 @@
|
|
|
#include <cctype>
|
|
#include <cctype>
|
|
|
#include <cstdio>
|
|
#include <cstdio>
|
|
|
#include <functional>
|
|
#include <functional>
|
|
|
|
|
+#include <iterator>
|
|
|
#include <sstream>
|
|
#include <sstream>
|
|
|
#include <type_traits>
|
|
#include <type_traits>
|
|
|
#include <utility>
|
|
#include <utility>
|
|
|
|
|
|
|
|
-#include <cm/iterator>
|
|
|
|
|
#include <cm/memory>
|
|
#include <cm/memory>
|
|
|
#include <cm/optional>
|
|
#include <cm/optional>
|
|
|
#include <cm/string_view>
|
|
#include <cm/string_view>
|
|
@@ -663,6 +663,7 @@ void cmGlobalNinjaGenerator::Generate()
|
|
|
|
|
|
|
|
void cmGlobalNinjaGenerator::CleanMetaData()
|
|
void cmGlobalNinjaGenerator::CleanMetaData()
|
|
|
{
|
|
{
|
|
|
|
|
+ constexpr size_t ninja_tool_arg_size = 8; // 2 `-_` flags and 4 separators
|
|
|
auto run_ninja_tool = [this](std::vector<char const*> const& args) {
|
|
auto run_ninja_tool = [this](std::vector<char const*> const& args) {
|
|
|
std::vector<std::string> command;
|
|
std::vector<std::string> command;
|
|
|
command.push_back(this->NinjaCommand);
|
|
command.push_back(this->NinjaCommand);
|
|
@@ -705,19 +706,27 @@ void cmGlobalNinjaGenerator::CleanMetaData()
|
|
|
run_ninja_tool({ "recompact" });
|
|
run_ninja_tool({ "recompact" });
|
|
|
}
|
|
}
|
|
|
if (this->NinjaSupportsRestatTool && this->OutputPathPrefix.empty()) {
|
|
if (this->NinjaSupportsRestatTool && this->OutputPathPrefix.empty()) {
|
|
|
- // XXX(ninja): We only list `build.ninja` entry files here because CMake
|
|
|
|
|
- // *always* rewrites these files on a reconfigure. If CMake ever gets
|
|
|
|
|
- // smarter about this, all CMake-time created/edited files listed as
|
|
|
|
|
- // outputs for the reconfigure build statement will need to be listed here.
|
|
|
|
|
cmNinjaDeps outputs;
|
|
cmNinjaDeps outputs;
|
|
|
this->AddRebuildManifestOutputs(outputs);
|
|
this->AddRebuildManifestOutputs(outputs);
|
|
|
- std::vector<char const*> args;
|
|
|
|
|
- args.reserve(outputs.size() + 1);
|
|
|
|
|
- args.push_back("restat");
|
|
|
|
|
- for (auto const& output : outputs) {
|
|
|
|
|
- args.push_back(output.c_str());
|
|
|
|
|
|
|
+ auto output_it = outputs.begin();
|
|
|
|
|
+ size_t static_arg_size = ninja_tool_arg_size + this->NinjaCommand.size() +
|
|
|
|
|
+ this->GetCMakeInstance()->GetHomeOutputDirectory().size();
|
|
|
|
|
+ // The Windows command-line length limit is 32768. Leave plenty.
|
|
|
|
|
+ constexpr size_t maximum_arg_size = 30000;
|
|
|
|
|
+ while (output_it != outputs.end()) {
|
|
|
|
|
+ size_t total_arg_size = static_arg_size;
|
|
|
|
|
+ std::vector<char const*> args;
|
|
|
|
|
+ args.reserve(std::distance(output_it, outputs.end()) + 1);
|
|
|
|
|
+ args.push_back("restat");
|
|
|
|
|
+ total_arg_size += 7; // restat + 1
|
|
|
|
|
+ while (output_it != outputs.end() &&
|
|
|
|
|
+ total_arg_size + output_it->size() + 1 < maximum_arg_size) {
|
|
|
|
|
+ args.push_back(output_it->c_str());
|
|
|
|
|
+ total_arg_size += output_it->size() + 1;
|
|
|
|
|
+ ++output_it;
|
|
|
|
|
+ }
|
|
|
|
|
+ run_ninja_tool(args);
|
|
|
}
|
|
}
|
|
|
- run_ninja_tool(args);
|
|
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|