summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2021-05-03 14:53:40 (GMT)
committerKitware Robot <kwrobot@kitware.com>2021-05-03 14:53:50 (GMT)
commit4419b944fdd7f1eaea06411224cfbe6242628c18 (patch)
tree0a65ff701c78b860ea15b7c5e0103fe2de1e678a /Source
parent4df3f5300a13827336ca5329b53834cf0fb63a7d (diff)
parentad08f93ee40a1cc855c403c1cc738237511224e3 (diff)
downloadCMake-4419b944fdd7f1eaea06411224cfbe6242628c18.zip
CMake-4419b944fdd7f1eaea06411224cfbe6242628c18.tar.gz
CMake-4419b944fdd7f1eaea06411224cfbe6242628c18.tar.bz2
Merge topic 'ninja-multi-long-command-line-config'
ad08f93ee4 Ninja Multi-Config: Split long command lines by config Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !6067
Diffstat (limited to 'Source')
-rw-r--r--Source/cmLocalNinjaGenerator.cxx17
-rw-r--r--Source/cmLocalNinjaGenerator.h5
-rw-r--r--Source/cmNinjaNormalTargetGenerator.cxx30
-rw-r--r--Source/cmNinjaTargetGenerator.cxx25
-rw-r--r--Source/cmNinjaTargetGenerator.h3
-rw-r--r--Source/cmNinjaUtilityTargetGenerator.cxx4
6 files changed, 54 insertions, 30 deletions
diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx
index c2a6410..588f70b 100644
--- a/Source/cmLocalNinjaGenerator.cxx
+++ b/Source/cmLocalNinjaGenerator.cxx
@@ -410,7 +410,8 @@ void cmLocalNinjaGenerator::AppendCustomCommandDeps(
}
std::string cmLocalNinjaGenerator::WriteCommandScript(
- std::vector<std::string> const& cmdLines, std::string const& customStep,
+ std::vector<std::string> const& cmdLines, std::string const& outputConfig,
+ std::string const& commandConfig, std::string const& customStep,
cmGeneratorTarget const* target) const
{
std::string scriptPath;
@@ -419,9 +420,13 @@ std::string cmLocalNinjaGenerator::WriteCommandScript(
} else {
scriptPath = cmStrCat(this->GetCurrentBinaryDirectory(), "/CMakeFiles");
}
+ scriptPath += this->GetGlobalNinjaGenerator()->ConfigDirectory(outputConfig);
cmSystemTools::MakeDirectory(scriptPath);
scriptPath += '/';
scriptPath += customStep;
+ if (this->GlobalGenerator->IsMultiConfig()) {
+ scriptPath += cmStrCat('-', commandConfig);
+ }
#ifdef _WIN32
scriptPath += ".bat";
#else
@@ -464,7 +469,8 @@ std::string cmLocalNinjaGenerator::WriteCommandScript(
}
std::string cmLocalNinjaGenerator::BuildCommandLine(
- std::vector<std::string> const& cmdLines, std::string const& customStep,
+ std::vector<std::string> const& cmdLines, std::string const& outputConfig,
+ std::string const& commandConfig, std::string const& customStep,
cmGeneratorTarget const* target) const
{
// If we have no commands but we need to build a command anyway, use noop.
@@ -483,8 +489,8 @@ std::string cmLocalNinjaGenerator::BuildCommandLine(
cmdLinesTotal += cmd.length() + 6;
}
if (cmdLinesTotal > cmSystemTools::CalculateCommandLineLengthLimit() / 2) {
- std::string const scriptPath =
- this->WriteCommandScript(cmdLines, customStep, target);
+ std::string const scriptPath = this->WriteCommandScript(
+ cmdLines, outputConfig, commandConfig, customStep, target);
std::string cmd
#ifndef _WIN32
= "/bin/sh "
@@ -697,7 +703,8 @@ void cmLocalNinjaGenerator::WriteCustomCommandBuildStatement(
}
gg->WriteCustomCommandBuild(
- this->BuildCommandLine(cmdLines, customStep),
+ this->BuildCommandLine(cmdLines, ccg.GetOutputConfig(), fileConfig,
+ customStep),
this->ConstructComment(ccg), "Custom command for " + ninjaOutputs[0],
depfile, cc->GetJobPool(), cc->GetUsesTerminal(),
/*restat*/ !symbolic || !byproducts.empty(), ninjaOutputs, fileConfig,
diff --git a/Source/cmLocalNinjaGenerator.h b/Source/cmLocalNinjaGenerator.h
index 8b6824f..a73fa27 100644
--- a/Source/cmLocalNinjaGenerator.h
+++ b/Source/cmLocalNinjaGenerator.h
@@ -61,7 +61,8 @@ public:
}
std::string BuildCommandLine(
- std::vector<std::string> const& cmdLines,
+ std::vector<std::string> const& cmdLines, std::string const& outputConfig,
+ std::string const& commandConfig,
std::string const& customStep = std::string(),
cmGeneratorTarget const* target = nullptr) const;
@@ -119,6 +120,8 @@ private:
std::string MakeCustomLauncher(cmCustomCommandGenerator const& ccg);
std::string WriteCommandScript(std::vector<std::string> const& cmdLines,
+ std::string const& outputConfig,
+ std::string const& commandConfig,
std::string const& customStep,
cmGeneratorTarget const* target) const;
diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx
index 1d511f2..1b514b8 100644
--- a/Source/cmNinjaNormalTargetGenerator.cxx
+++ b/Source/cmNinjaNormalTargetGenerator.cxx
@@ -287,7 +287,8 @@ void cmNinjaNormalTargetGenerator::WriteNvidiaDeviceLinkRule(
// If there is no ranlib the command will be ":". Skip it.
cm::erase_if(linkCmds, cmNinjaRemoveNoOpCommands());
- rule.Command = this->GetLocalGenerator()->BuildCommandLine(linkCmds);
+ rule.Command =
+ this->GetLocalGenerator()->BuildCommandLine(linkCmds, config, config);
// Write the linker rule with response file if needed.
rule.Comment =
@@ -310,7 +311,8 @@ void cmNinjaNormalTargetGenerator::WriteDeviceLinkRules(
cmNinjaRule rule(this->LanguageLinkerCudaDeviceRule(config));
rule.Command = this->GetLocalGenerator()->BuildCommandLine(
{ cmStrCat(mf->GetRequiredDefinition("CMAKE_CUDA_DEVICE_LINKER"),
- " -arch=$ARCH $REGISTER -o=$out $in") });
+ " -arch=$ARCH $REGISTER -o=$out $in") },
+ config, config);
rule.Comment = "Rule for CUDA device linking.";
rule.Description = "Linking CUDA $out";
this->GetGlobalGenerator()->AddRule(rule);
@@ -336,7 +338,8 @@ void cmNinjaNormalTargetGenerator::WriteDeviceLinkRules(
compileCmd, vars);
rule.Name = this->LanguageLinkerCudaDeviceCompileRule(config);
- rule.Command = this->GetLocalGenerator()->BuildCommandLine({ compileCmd });
+ rule.Command = this->GetLocalGenerator()->BuildCommandLine({ compileCmd },
+ config, config);
rule.Comment = "Rule for compiling CUDA device stubs.";
rule.Description = "Compiling CUDA device stub $out";
this->GetGlobalGenerator()->AddRule(rule);
@@ -345,7 +348,8 @@ void cmNinjaNormalTargetGenerator::WriteDeviceLinkRules(
rule.Command = this->GetLocalGenerator()->BuildCommandLine(
{ cmStrCat(mf->GetRequiredDefinition("CMAKE_CUDA_FATBINARY"),
" -64 -cmdline=--compile-only -compress-all -link "
- "--embedded-fatbin=$out $PROFILES") });
+ "--embedded-fatbin=$out $PROFILES") },
+ config, config);
rule.Comment = "Rule for CUDA fatbinaries.";
rule.Description = "Creating fatbinary $out";
this->GetGlobalGenerator()->AddRule(rule);
@@ -475,7 +479,8 @@ void cmNinjaNormalTargetGenerator::WriteLinkRule(bool useResponseFile,
linkCmds.insert(linkCmds.begin(), "$PRE_LINK");
linkCmds.emplace_back("$POST_BUILD");
- rule.Command = this->GetLocalGenerator()->BuildCommandLine(linkCmds);
+ rule.Command =
+ this->GetLocalGenerator()->BuildCommandLine(linkCmds, config, config);
// Write the linker rule with response file if needed.
rule.Comment =
@@ -500,7 +505,8 @@ void cmNinjaNormalTargetGenerator::WriteLinkRule(bool useResponseFile,
std::vector<std::string> cmd;
cmd.push_back(cmakeCommand + " -E cmake_symlink_executable $in $out");
cmd.emplace_back("$POST_BUILD");
- rule.Command = this->GetLocalGenerator()->BuildCommandLine(cmd);
+ rule.Command =
+ this->GetLocalGenerator()->BuildCommandLine(cmd, config, config);
}
rule.Description = "Creating executable symlink $out";
rule.Comment = "Rule for creating executable symlink.";
@@ -512,7 +518,8 @@ void cmNinjaNormalTargetGenerator::WriteLinkRule(bool useResponseFile,
cmd.push_back(cmakeCommand +
" -E cmake_symlink_library $in $SONAME $out");
cmd.emplace_back("$POST_BUILD");
- rule.Command = this->GetLocalGenerator()->BuildCommandLine(cmd);
+ rule.Command =
+ this->GetLocalGenerator()->BuildCommandLine(cmd, config, config);
}
rule.Description = "Creating library symlink $out";
rule.Comment = "Rule for creating library symlink.";
@@ -1312,10 +1319,11 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement(
preLinkCmdLines.push_back("cd " + homeOutDir);
}
- vars["PRE_LINK"] = localGen.BuildCommandLine(preLinkCmdLines, "pre-link",
- this->GeneratorTarget);
- std::string postBuildCmdLine = localGen.BuildCommandLine(
- postBuildCmdLines, "post-build", this->GeneratorTarget);
+ vars["PRE_LINK"] = localGen.BuildCommandLine(
+ preLinkCmdLines, config, fileConfig, "pre-link", this->GeneratorTarget);
+ std::string postBuildCmdLine =
+ localGen.BuildCommandLine(postBuildCmdLines, config, fileConfig,
+ "post-build", this->GeneratorTarget);
cmNinjaVars symlinkVars;
bool const symlinkNeeded =
diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx
index 2e0ffdb..f7777fc 100644
--- a/Source/cmNinjaTargetGenerator.cxx
+++ b/Source/cmNinjaTargetGenerator.cxx
@@ -539,7 +539,8 @@ cmNinjaRule GetScanRule(
cmRulePlaceholderExpander::RuleVariables const& vars,
const std::string& responseFlag, const std::string& flags,
cmRulePlaceholderExpander* const rulePlaceholderExpander,
- cmLocalNinjaGenerator* generator, std::vector<std::string> scanCmds)
+ cmLocalNinjaGenerator* generator, std::vector<std::string> scanCmds,
+ const std::string& outputConfig)
{
cmNinjaRule rule(ruleName);
// Scanning always uses a depfile for preprocessor dependencies.
@@ -580,7 +581,8 @@ cmNinjaRule GetScanRule(
for (std::string& scanCmd : scanCmds) {
rulePlaceholderExpander->ExpandRuleVariables(generator, scanCmd, scanVars);
}
- rule.Command = generator->BuildCommandLine(scanCmds);
+ rule.Command =
+ generator->BuildCommandLine(scanCmds, outputConfig, outputConfig);
return rule;
}
@@ -672,7 +674,7 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang,
auto scanRule = GetScanRule(
scanRuleName, vars, responseFlag, flags, rulePlaceholderExpander.get(),
- this->GetLocalGenerator(), std::move(scanCommands));
+ this->GetLocalGenerator(), std::move(scanCommands), config);
scanRule.Comment =
cmStrCat("Rule for generating ", lang, " dependencies.");
@@ -702,7 +704,7 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang,
auto scanRule = GetScanRule(
scanRuleName, vars, "", flags, rulePlaceholderExpander.get(),
- this->GetLocalGenerator(), std::move(scanCommands));
+ this->GetLocalGenerator(), std::move(scanCommands), config);
// Write the rule for generating dependencies for the given language.
scanRule.Comment = cmStrCat("Rule for generating ", lang,
@@ -734,7 +736,8 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang,
ddModmapArg, " --dd=$out @", rule.RspFile);
ddCmds.emplace_back(std::move(ccmd));
}
- rule.Command = this->GetLocalGenerator()->BuildCommandLine(ddCmds);
+ rule.Command =
+ this->GetLocalGenerator()->BuildCommandLine(ddCmds, config, config);
}
rule.Comment =
cmStrCat("Rule to generate ninja dyndep files for ", lang, '.');
@@ -930,7 +933,8 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang,
vars);
}
- rule.Command = this->GetLocalGenerator()->BuildCommandLine(compileCmds);
+ rule.Command =
+ this->GetLocalGenerator()->BuildCommandLine(compileCmds, config, config);
// Write the rule for compiling file of the given language.
rule.Comment = cmStrCat("Rule for compiling ", lang, " files.");
@@ -1248,7 +1252,7 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatement(
this->ExportObjectCompileCommand(
language, sourceFileName, objectDir, objectFileName, objectFileDir,
- vars["FLAGS"], vars["DEFINES"], vars["INCLUDES"]);
+ vars["FLAGS"], vars["DEFINES"], vars["INCLUDES"], config);
objBuild.Outputs.push_back(objectFileName);
if (firstForConfig) {
@@ -1619,7 +1623,8 @@ void cmNinjaTargetGenerator::ExportObjectCompileCommand(
std::string const& language, std::string const& sourceFileName,
std::string const& objectDir, std::string const& objectFileName,
std::string const& objectFileDir, std::string const& flags,
- std::string const& defines, std::string const& includes)
+ std::string const& defines, std::string const& includes,
+ std::string const& outputConfig)
{
if (!this->GeneratorTarget->GetPropertyAsBool("EXPORT_COMPILE_COMMANDS")) {
return;
@@ -1681,8 +1686,8 @@ void cmNinjaTargetGenerator::ExportObjectCompileCommand(
compileObjectVars);
}
- std::string cmdLine =
- this->GetLocalGenerator()->BuildCommandLine(compileCmds);
+ std::string cmdLine = this->GetLocalGenerator()->BuildCommandLine(
+ compileCmds, outputConfig, outputConfig);
this->GetGlobalGenerator()->AddCXXCompileCommand(cmdLine, sourceFileName);
}
diff --git a/Source/cmNinjaTargetGenerator.h b/Source/cmNinjaTargetGenerator.h
index 79dc622..3a28cef 100644
--- a/Source/cmNinjaTargetGenerator.h
+++ b/Source/cmNinjaTargetGenerator.h
@@ -162,7 +162,8 @@ protected:
std::string const& language, std::string const& sourceFileName,
std::string const& objectDir, std::string const& objectFileName,
std::string const& objectFileDir, std::string const& flags,
- std::string const& defines, std::string const& includes);
+ std::string const& defines, std::string const& includes,
+ std::string const& outputConfig);
void AdditionalCleanFiles(const std::string& config);
diff --git a/Source/cmNinjaUtilityTargetGenerator.cxx b/Source/cmNinjaUtilityTargetGenerator.cxx
index 92c5b52..7a04c47 100644
--- a/Source/cmNinjaUtilityTargetGenerator.cxx
+++ b/Source/cmNinjaUtilityTargetGenerator.cxx
@@ -139,8 +139,8 @@ void cmNinjaUtilityTargetGenerator::WriteUtilBuildStatements(
gg->WriteBuild(this->GetCommonFileStream(), phonyBuild);
}
} else {
- std::string command =
- lg->BuildCommandLine(commands, "utility", this->GeneratorTarget);
+ std::string command = lg->BuildCommandLine(
+ commands, config, fileConfig, "utility", this->GeneratorTarget);
std::string desc;
cmProp echoStr = genTarget->GetProperty("EchoString");
if (echoStr) {