cmNinjaTargetGenerator: cmStrCat usage

This commit is contained in:
Ben Boeckel
2020-02-11 03:27:06 -05:00
parent 9f6544048f
commit 6e65b869c3
+81 -79
View File
@@ -94,17 +94,19 @@ cmGlobalNinjaGenerator* cmNinjaTargetGenerator::GetGlobalGenerator() const
std::string cmNinjaTargetGenerator::LanguageCompilerRule( std::string cmNinjaTargetGenerator::LanguageCompilerRule(
const std::string& lang, const std::string& config) const const std::string& lang, const std::string& config) const
{ {
return lang + "_COMPILER__" + return cmStrCat(
cmGlobalNinjaGenerator::EncodeRuleName(this->GeneratorTarget->GetName()) + lang, "_COMPILER__",
"_" + config; cmGlobalNinjaGenerator::EncodeRuleName(this->GeneratorTarget->GetName()),
'_', config);
} }
std::string cmNinjaTargetGenerator::LanguagePreprocessRule( std::string cmNinjaTargetGenerator::LanguagePreprocessRule(
std::string const& lang, const std::string& config) const std::string const& lang, const std::string& config) const
{ {
return lang + "_PREPROCESS__" + return cmStrCat(
cmGlobalNinjaGenerator::EncodeRuleName(this->GeneratorTarget->GetName()) + lang, "_PREPROCESS__",
"_" + config; cmGlobalNinjaGenerator::EncodeRuleName(this->GeneratorTarget->GetName()),
'_', config);
} }
bool cmNinjaTargetGenerator::NeedExplicitPreprocessing( bool cmNinjaTargetGenerator::NeedExplicitPreprocessing(
@@ -129,9 +131,10 @@ bool cmNinjaTargetGenerator::CompilePreprocessedSourceWithDefines(
std::string cmNinjaTargetGenerator::LanguageDyndepRule( std::string cmNinjaTargetGenerator::LanguageDyndepRule(
const std::string& lang, const std::string& config) const const std::string& lang, const std::string& config) const
{ {
return lang + "_DYNDEP__" + return cmStrCat(
cmGlobalNinjaGenerator::EncodeRuleName(this->GeneratorTarget->GetName()) + lang, "_DYNDEP__",
"_" + config; cmGlobalNinjaGenerator::EncodeRuleName(this->GeneratorTarget->GetName()),
'_', config);
} }
bool cmNinjaTargetGenerator::NeedDyndep(std::string const& lang) const bool cmNinjaTargetGenerator::NeedDyndep(std::string const& lang) const
@@ -219,8 +222,8 @@ void cmNinjaTargetGenerator::AddIncludeFlags(std::string& languageFlags,
bool cmNinjaTargetGenerator::NeedDepTypeMSVC(const std::string& lang) const bool cmNinjaTargetGenerator::NeedDepTypeMSVC(const std::string& lang) const
{ {
std::string const& deptype = std::string const& deptype = this->GetMakefile()->GetSafeDefinition(
this->GetMakefile()->GetSafeDefinition("CMAKE_NINJA_DEPTYPE_" + lang); cmStrCat("CMAKE_NINJA_DEPTYPE_", lang));
if (deptype == "msvc") { if (deptype == "msvc") {
return true; return true;
} }
@@ -355,13 +358,12 @@ std::string cmNinjaTargetGenerator::GetObjectFilePath(
{ {
std::string path = this->LocalGenerator->GetHomeRelativeOutputPath(); std::string path = this->LocalGenerator->GetHomeRelativeOutputPath();
if (!path.empty()) { if (!path.empty()) {
path += "/"; path += '/';
} }
std::string const& objectName = this->GeneratorTarget->GetObjectName(source); std::string const& objectName = this->GeneratorTarget->GetObjectName(source);
path += this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget); path += cmStrCat(
path += this->GetGlobalGenerator()->ConfigDirectory(config); this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget),
path += "/"; this->GetGlobalGenerator()->ConfigDirectory(config), '/', objectName);
path += objectName;
return path; return path;
} }
@@ -389,16 +391,15 @@ std::string cmNinjaTargetGenerator::GetPreprocessedFilePath(
this->GetGlobalGenerator()->GetLanguageOutputExtension(*source); this->GetGlobalGenerator()->GetLanguageOutputExtension(*source);
assert(objName.size() >= objExt.size()); assert(objName.size() >= objExt.size());
std::string const ppName = std::string const ppName =
objName.substr(0, objName.size() - objExt.size()) + "-pp." + ppExt; cmStrCat(objName.substr(0, objName.size() - objExt.size()), "-pp.", ppExt);
std::string path = this->LocalGenerator->GetHomeRelativeOutputPath(); std::string path = this->LocalGenerator->GetHomeRelativeOutputPath();
if (!path.empty()) { if (!path.empty()) {
path += "/"; path += '/';
} }
path += this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget); path +=
path += this->GetGlobalGenerator()->ConfigDirectory(config); cmStrCat(this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget),
path += "/"; this->GetGlobalGenerator()->ConfigDirectory(config), '/', ppName);
path += ppName;
return path; return path;
} }
@@ -407,13 +408,11 @@ std::string cmNinjaTargetGenerator::GetDyndepFilePath(
{ {
std::string path = this->LocalGenerator->GetHomeRelativeOutputPath(); std::string path = this->LocalGenerator->GetHomeRelativeOutputPath();
if (!path.empty()) { if (!path.empty()) {
path += "/"; path += '/';
} }
path += this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget); path += cmStrCat(
path += this->GetGlobalGenerator()->ConfigDirectory(config); this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget),
path += "/"; this->GetGlobalGenerator()->ConfigDirectory(config), '/', lang, ".dd");
path += lang;
path += ".dd";
return path; return path;
} }
@@ -442,8 +441,7 @@ std::string cmNinjaTargetGenerator::GetTargetFilePath(
if (path.empty() || path == ".") { if (path.empty() || path == ".") {
return name; return name;
} }
path += "/"; path += cmStrCat('/', name);
path += name;
return path; return path;
} }
@@ -522,7 +520,7 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang,
bool const lang_supports_response = lang != "RC"; bool const lang_supports_response = lang != "RC";
if (lang_supports_response && this->ForceResponseFile()) { if (lang_supports_response && this->ForceResponseFile()) {
std::string const responseFlagVar = std::string const responseFlagVar =
"CMAKE_" + lang + "_RESPONSE_FILE_FLAG"; cmStrCat("CMAKE_", lang, "_RESPONSE_FILE_FLAG");
responseFlag = this->Makefile->GetSafeDefinition(responseFlagVar); responseFlag = this->Makefile->GetSafeDefinition(responseFlagVar);
if (responseFlag.empty() && lang != "CUDA") { if (responseFlag.empty() && lang != "CUDA") {
responseFlag = "@"; responseFlag = "@";
@@ -587,7 +585,7 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang,
rule.RspFile = "$RSP_FILE"; rule.RspFile = "$RSP_FILE";
rule.RspContent = rule.RspContent =
cmStrCat(' ', ppVars.Defines, ' ', ppVars.Includes, ' ', ppFlags); cmStrCat(' ', ppVars.Defines, ' ', ppVars.Includes, ' ', ppFlags);
ppFlags = responseFlag + rule.RspFile; ppFlags = cmStrCat(responseFlag, rule.RspFile);
ppVars.Defines = ""; ppVars.Defines = "";
ppVars.Includes = ""; ppVars.Includes = "";
} }
@@ -658,7 +656,7 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang,
rule.RspFile = "$RSP_FILE"; rule.RspFile = "$RSP_FILE";
rule.RspContent = rule.RspContent =
cmStrCat(' ', vars.Defines, ' ', vars.Includes, ' ', flags); cmStrCat(' ', vars.Defines, ' ', vars.Includes, ' ', flags);
flags = responseFlag + rule.RspFile; flags = cmStrCat(responseFlag, rule.RspFile);
vars.Defines = ""; vars.Defines = "";
vars.Includes = ""; vars.Includes = "";
} }
@@ -671,7 +669,7 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang,
rule.DepType = "msvc"; rule.DepType = "msvc";
rule.DepFile.clear(); rule.DepFile.clear();
flags += " /showIncludes"; flags += " /showIncludes";
} else if (mf->IsOn("CMAKE_NINJA_CMCLDEPS_" + lang)) { } else if (mf->IsOn(cmStrCat("CMAKE_NINJA_CMCLDEPS_", lang))) {
// For the MS resource compiler we need cmcldeps, but skip dependencies // For the MS resource compiler we need cmcldeps, but skip dependencies
// for source-file try_compile cases because they are always fresh. // for source-file try_compile cases because they are always fresh.
if (!mf->GetIsSourceFileTryCompile()) { if (!mf->GetIsSourceFileTryCompile()) {
@@ -688,14 +686,14 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang,
} else { } else {
rule.DepType = "gcc"; rule.DepType = "gcc";
rule.DepFile = "$DEP_FILE"; rule.DepFile = "$DEP_FILE";
const std::string flagsName = "CMAKE_DEPFILE_FLAGS_" + lang; const std::string flagsName = cmStrCat("CMAKE_DEPFILE_FLAGS_", lang);
std::string depfileFlags = mf->GetSafeDefinition(flagsName); std::string depfileFlags = mf->GetSafeDefinition(flagsName);
if (!depfileFlags.empty()) { if (!depfileFlags.empty()) {
cmSystemTools::ReplaceString(depfileFlags, "<DEPFILE>", "$DEP_FILE"); cmSystemTools::ReplaceString(depfileFlags, "<DEPFILE>", "$DEP_FILE");
cmSystemTools::ReplaceString(depfileFlags, "<OBJECT>", "$out"); cmSystemTools::ReplaceString(depfileFlags, "<OBJECT>", "$out");
cmSystemTools::ReplaceString(depfileFlags, "<CMAKE_C_COMPILER>", cmSystemTools::ReplaceString(depfileFlags, "<CMAKE_C_COMPILER>",
mf->GetDefinition("CMAKE_C_COMPILER")); mf->GetDefinition("CMAKE_C_COMPILER"));
flags += " " + depfileFlags; flags += cmStrCat(' ', depfileFlags);
} }
} }
@@ -718,7 +716,7 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang,
const std::string& compileCmd = mf->GetRequiredDefinition(cmdVar); const std::string& compileCmd = mf->GetRequiredDefinition(cmdVar);
cmExpandList(compileCmd, compileCmds); cmExpandList(compileCmd, compileCmds);
} else { } else {
const std::string cmdVar = "CMAKE_" + lang + "_COMPILE_OBJECT"; const std::string cmdVar = cmStrCat("CMAKE_", lang, "_COMPILE_OBJECT");
const std::string& compileCmd = mf->GetRequiredDefinition(cmdVar); const std::string& compileCmd = mf->GetRequiredDefinition(cmdVar);
cmExpandList(compileCmd, compileCmds); cmExpandList(compileCmd, compileCmds);
} }
@@ -728,7 +726,7 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang,
if (!compileCmds.empty() && if (!compileCmds.empty() &&
(lang == "C" || lang == "CXX" || lang == "Fortran" || lang == "CUDA" || (lang == "C" || lang == "CXX" || lang == "Fortran" || lang == "CUDA" ||
lang == "OBJC" || lang == "OBJCXX")) { lang == "OBJC" || lang == "OBJCXX")) {
std::string const clauncher_prop = lang + "_COMPILER_LAUNCHER"; std::string const clauncher_prop = cmStrCat(lang, "_COMPILER_LAUNCHER");
const char* clauncher = this->GeneratorTarget->GetProperty(clauncher_prop); const char* clauncher = this->GeneratorTarget->GetProperty(clauncher_prop);
if (clauncher && *clauncher) { if (clauncher && *clauncher) {
compilerLauncher = clauncher; compilerLauncher = clauncher;
@@ -737,13 +735,13 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang,
// Maybe insert an include-what-you-use runner. // Maybe insert an include-what-you-use runner.
if (!compileCmds.empty() && (lang == "C" || lang == "CXX")) { if (!compileCmds.empty() && (lang == "C" || lang == "CXX")) {
std::string const iwyu_prop = lang + "_INCLUDE_WHAT_YOU_USE"; std::string const iwyu_prop = cmStrCat(lang, "_INCLUDE_WHAT_YOU_USE");
const char* iwyu = this->GeneratorTarget->GetProperty(iwyu_prop); const char* iwyu = this->GeneratorTarget->GetProperty(iwyu_prop);
std::string const tidy_prop = lang + "_CLANG_TIDY"; std::string const tidy_prop = cmStrCat(lang, "_CLANG_TIDY");
const char* tidy = this->GeneratorTarget->GetProperty(tidy_prop); const char* tidy = this->GeneratorTarget->GetProperty(tidy_prop);
std::string const cpplint_prop = lang + "_CPPLINT"; std::string const cpplint_prop = cmStrCat(lang, "_CPPLINT");
const char* cpplint = this->GeneratorTarget->GetProperty(cpplint_prop); const char* cpplint = this->GeneratorTarget->GetProperty(cpplint_prop);
std::string const cppcheck_prop = lang + "_CPPCHECK"; std::string const cppcheck_prop = cmStrCat(lang, "_CPPCHECK");
const char* cppcheck = this->GeneratorTarget->GetProperty(cppcheck_prop); const char* cppcheck = this->GeneratorTarget->GetProperty(cppcheck_prop);
if ((iwyu && *iwyu) || (tidy && *tidy) || (cpplint && *cpplint) || if ((iwyu && *iwyu) || (tidy && *tidy) || (cpplint && *cpplint) ||
(cppcheck && *cppcheck)) { (cppcheck && *cppcheck)) {
@@ -751,18 +749,19 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang,
if (!compilerLauncher.empty()) { if (!compilerLauncher.empty()) {
// In __run_co_compile case the launcher command is supplied // In __run_co_compile case the launcher command is supplied
// via --launcher=<maybe-list> and consumed // via --launcher=<maybe-list> and consumed
run_iwyu += " --launcher="; run_iwyu +=
run_iwyu += this->LocalGenerator->EscapeForShell(compilerLauncher); cmStrCat(" --launcher=",
this->LocalGenerator->EscapeForShell(compilerLauncher));
compilerLauncher.clear(); compilerLauncher.clear();
} }
if (iwyu && *iwyu) { if (iwyu && *iwyu) {
run_iwyu += " --iwyu="; run_iwyu += cmStrCat(" --iwyu=",
run_iwyu += this->GetLocalGenerator()->EscapeForShell(iwyu); this->GetLocalGenerator()->EscapeForShell(iwyu));
} }
if (tidy && *tidy) { if (tidy && *tidy) {
run_iwyu += " --tidy="; run_iwyu += " --tidy=";
const char* driverMode = this->Makefile->GetDefinition( const char* driverMode = this->Makefile->GetDefinition(
"CMAKE_" + lang + "_CLANG_TIDY_DRIVER_MODE"); cmStrCat("CMAKE_", lang, "_CLANG_TIDY_DRIVER_MODE"));
if (!(driverMode && *driverMode)) { if (!(driverMode && *driverMode)) {
driverMode = lang == "C" ? "gcc" : "g++"; driverMode = lang == "C" ? "gcc" : "g++";
} }
@@ -770,12 +769,12 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang,
cmStrCat(tidy, ";--extra-arg-before=--driver-mode=", driverMode)); cmStrCat(tidy, ";--extra-arg-before=--driver-mode=", driverMode));
} }
if (cpplint && *cpplint) { if (cpplint && *cpplint) {
run_iwyu += " --cpplint="; run_iwyu += cmStrCat(
run_iwyu += this->GetLocalGenerator()->EscapeForShell(cpplint); " --cpplint=", this->GetLocalGenerator()->EscapeForShell(cpplint));
} }
if (cppcheck && *cppcheck) { if (cppcheck && *cppcheck) {
run_iwyu += " --cppcheck="; run_iwyu += cmStrCat(
run_iwyu += this->GetLocalGenerator()->EscapeForShell(cppcheck); " --cppcheck=", this->GetLocalGenerator()->EscapeForShell(cppcheck));
} }
if ((tidy && *tidy) || (cpplint && *cpplint) || if ((tidy && *tidy) || (cpplint && *cpplint) ||
(cppcheck && *cppcheck)) { (cppcheck && *cppcheck)) {
@@ -797,7 +796,7 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang,
i = this->LocalGenerator->EscapeForShell(i); i = this->LocalGenerator->EscapeForShell(i);
} }
} }
compileCmds.front().insert(0, cmJoin(args, " ") + " "); compileCmds.front().insert(0, cmStrCat(cmJoin(args, " "), ' '));
} }
if (!compileCmds.empty()) { if (!compileCmds.empty()) {
@@ -872,7 +871,8 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatements(
{ {
cmNinjaBuild build("phony"); cmNinjaBuild build("phony");
build.Comment = "Order-only phony target for " + this->GetTargetName(); build.Comment =
cmStrCat("Order-only phony target for ", this->GetTargetName());
build.Outputs.push_back(this->OrderDependsTargetForTarget(config)); build.Outputs.push_back(this->OrderDependsTargetForTarget(config));
cmNinjaDeps& orderOnlyDeps = build.OrderOnlyDeps; cmNinjaDeps& orderOnlyDeps = build.OrderOnlyDeps;
@@ -952,16 +952,16 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatements(
this->GetImplFileStream(fileConfig) << "\n"; this->GetImplFileStream(fileConfig) << "\n";
if (!this->Configs[config].SwiftOutputMap.empty()) { if (!this->Configs[config].SwiftOutputMap.empty()) {
std::string const mapFilePath = std::string const mapFilePath = cmStrCat(
this->GeneratorTarget->GetSupportDirectory() + "/output-file-map.json"; this->GeneratorTarget->GetSupportDirectory(), "/output-file-map.json");
std::string const targetSwiftDepsPath = [this, config]() -> std::string { std::string const targetSwiftDepsPath = [this, config]() -> std::string {
cmGeneratorTarget const* target = this->GeneratorTarget; cmGeneratorTarget const* target = this->GeneratorTarget;
if (const char* name = target->GetProperty("Swift_DEPENDENCIES_FILE")) { if (const char* name = target->GetProperty("Swift_DEPENDENCIES_FILE")) {
return name; return name;
} }
return this->ConvertToNinjaPath(target->GetSupportDirectory() + "/" + return this->ConvertToNinjaPath(
config + "/" + target->GetName() + cmStrCat(target->GetSupportDirectory(), '/', config, '/',
".swiftdeps"); target->GetName(), ".swiftdeps"));
}(); }();
// build the global target dependencies // build the global target dependencies
@@ -993,7 +993,7 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatement(
std::string cmakeVarLang = cmStrCat("CMAKE_", language); std::string cmakeVarLang = cmStrCat("CMAKE_", language);
// build response file name // build response file name
std::string cmakeLinkVar = cmakeVarLang + "_RESPONSE_FILE_FLAG"; std::string cmakeLinkVar = cmStrCat(cmakeVarLang, "_RESPONSE_FILE_FLAG");
const char* flag = GetMakefile()->GetDefinition(cmakeLinkVar); const char* flag = GetMakefile()->GetDefinition(cmakeLinkVar);
@@ -1018,14 +1018,15 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatement(
if (!replaceExt) { if (!replaceExt) {
// use original code // use original code
vars["DEP_FILE"] = this->GetLocalGenerator()->ConvertToOutputFormat( vars["DEP_FILE"] = this->GetLocalGenerator()->ConvertToOutputFormat(
objectFileName + ".d", cmOutputConverter::SHELL); cmStrCat(objectFileName, ".d"), cmOutputConverter::SHELL);
} else { } else {
// Replace the original source file extension with the // Replace the original source file extension with the
// depend file extension. // depend file extension.
std::string dependFileName = std::string dependFileName = cmStrCat(
cmSystemTools::GetFilenameWithoutLastExtension(objectFileName) + ".d"; cmSystemTools::GetFilenameWithoutLastExtension(objectFileName), ".d");
vars["DEP_FILE"] = this->GetLocalGenerator()->ConvertToOutputFormat( vars["DEP_FILE"] = this->GetLocalGenerator()->ConvertToOutputFormat(
objectFileDir + "/" + dependFileName, cmOutputConverter::SHELL); cmStrCat(objectFileDir, '/', dependFileName),
cmOutputConverter::SHELL);
} }
} }
@@ -1100,7 +1101,7 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatement(
this->ConvertToNinjaPath(this->GetPreprocessedFilePath(source, config)); this->ConvertToNinjaPath(this->GetPreprocessedFilePath(source, config));
ppBuild.Outputs.push_back(ppFileName); ppBuild.Outputs.push_back(ppFileName);
ppBuild.RspFile = ppFileName + ".rsp"; ppBuild.RspFile = cmStrCat(ppFileName, ".rsp");
bool const compilePP = this->UsePreprocessedSource(language); bool const compilePP = this->UsePreprocessedSource(language);
bool const compilePPWithDefines = bool const compilePPWithDefines =
@@ -1129,7 +1130,7 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatement(
// In case compilation requires flags that are incompatible with // In case compilation requires flags that are incompatible with
// preprocessing, include them here. // preprocessing, include them here.
std::string const& postFlag = this->Makefile->GetSafeDefinition( std::string const& postFlag = this->Makefile->GetSafeDefinition(
"CMAKE_" + language + "_POSTPROCESS_FLAG"); cmStrCat("CMAKE_", language, "_POSTPROCESS_FLAG"));
this->LocalGenerator->AppendFlags(vars["FLAGS"], postFlag); this->LocalGenerator->AppendFlags(vars["FLAGS"], postFlag);
} }
@@ -1157,13 +1158,13 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatement(
sourceDirectory, this->GeneratorTarget, language, false, false, sourceDirectory, this->GeneratorTarget, language, false, false,
config); config);
vars["INCLUDES"] = sourceDirectoryFlag + " " + vars["INCLUDES"]; vars["INCLUDES"] = cmStrCat(sourceDirectoryFlag, ' ', vars["INCLUDES"]);
} }
// Explicit preprocessing always uses a depfile. // Explicit preprocessing always uses a depfile.
ppBuild.Variables["DEP_FILE"] = ppBuild.Variables["DEP_FILE"] =
this->GetLocalGenerator()->ConvertToOutputFormat( this->GetLocalGenerator()->ConvertToOutputFormat(
objectFileName + ".pp.d", cmOutputConverter::SHELL); cmStrCat(objectFileName, ".pp.d"), cmOutputConverter::SHELL);
if (compilePP) { if (compilePP) {
// The actual compilation does not need a depfile because it // The actual compilation does not need a depfile because it
// depends on the already-preprocessed source. // depends on the already-preprocessed source.
@@ -1176,7 +1177,7 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatement(
ppBuild.Variables["OBJ_FILE"] = objectFileName; ppBuild.Variables["OBJ_FILE"] = objectFileName;
// Tell dependency scanner where to store dyndep intermediate results. // Tell dependency scanner where to store dyndep intermediate results.
std::string const ddiFile = objectFileName + ".ddi"; std::string const ddiFile = cmStrCat(objectFileName, ".ddi");
ppBuild.Variables["DYNDEP_INTERMEDIATE_FILE"] = ddiFile; ppBuild.Variables["DYNDEP_INTERMEDIATE_FILE"] = ddiFile;
ppBuild.ImplicitOuts.push_back(ddiFile); ppBuild.ImplicitOuts.push_back(ddiFile);
if (firstForConfig) { if (firstForConfig) {
@@ -1215,7 +1216,7 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatement(
this->SetMsvcTargetPdbVariable(vars, config); this->SetMsvcTargetPdbVariable(vars, config);
objBuild.RspFile = objectFileName + ".rsp"; objBuild.RspFile = cmStrCat(objectFileName, ".rsp");
if (language == "Swift") { if (language == "Swift") {
this->EmitSwiftDependencyInfo(source, config); this->EmitSwiftDependencyInfo(source, config);
@@ -1241,8 +1242,8 @@ void cmNinjaTargetGenerator::WriteTargetDependInfo(std::string const& lang,
{ {
Json::Value tdi(Json::objectValue); Json::Value tdi(Json::objectValue);
tdi["language"] = lang; tdi["language"] = lang;
tdi["compiler-id"] = tdi["compiler-id"] = this->Makefile->GetSafeDefinition(
this->Makefile->GetSafeDefinition("CMAKE_" + lang + "_COMPILER_ID"); cmStrCat("CMAKE_", lang, "_COMPILER_ID"));
if (lang == "Fortran") { if (lang == "Fortran") {
std::string mod_dir = this->GeneratorTarget->GetFortranModuleDirectory( std::string mod_dir = this->GeneratorTarget->GetFortranModuleDirectory(
@@ -1294,13 +1295,13 @@ void cmNinjaTargetGenerator::EmitSwiftDependencyInfo(
if (const char* name = source->GetProperty("Swift_DEPENDENCIES_FILE")) { if (const char* name = source->GetProperty("Swift_DEPENDENCIES_FILE")) {
return name; return name;
} }
return objectFilePath + ".swiftdeps"; return cmStrCat(objectFilePath, ".swiftdeps");
}(); }();
std::string const swiftDiaPath = [source, objectFilePath]() -> std::string { std::string const swiftDiaPath = [source, objectFilePath]() -> std::string {
if (const char* name = source->GetProperty("Swift_DIAGNOSTICS_FILE")) { if (const char* name = source->GetProperty("Swift_DIAGNOSTICS_FILE")) {
return name; return name;
} }
return objectFilePath + ".dia"; return cmStrCat(objectFilePath, ".dia");
}(); }();
std::string const makeDepsPath = [this, source, config]() -> std::string { std::string const makeDepsPath = [this, source, config]() -> std::string {
cmLocalNinjaGenerator const* local = this->GetLocalGenerator(); cmLocalNinjaGenerator const* local = this->GetLocalGenerator();
@@ -1310,12 +1311,13 @@ void cmNinjaTargetGenerator::EmitSwiftDependencyInfo(
cmSystemTools::GetFilenamePath(objectFileName); cmSystemTools::GetFilenamePath(objectFileName);
if (this->Makefile->IsOn("CMAKE_Swift_DEPFLE_EXTNSION_REPLACE")) { if (this->Makefile->IsOn("CMAKE_Swift_DEPFLE_EXTNSION_REPLACE")) {
std::string dependFileName = std::string dependFileName = cmStrCat(
cmSystemTools::GetFilenameWithoutLastExtension(objectFileName) + ".d"; cmSystemTools::GetFilenameWithoutLastExtension(objectFileName), ".d");
return local->ConvertToOutputFormat(objectFileDir + "/" + dependFileName, return local->ConvertToOutputFormat(
cmOutputConverter::SHELL); cmStrCat(objectFileDir, '/', dependFileName),
cmOutputConverter::SHELL);
} }
return local->ConvertToOutputFormat(objectFileName + ".d", return local->ConvertToOutputFormat(cmStrCat(objectFileName, ".d"),
cmOutputConverter::SHELL); cmOutputConverter::SHELL);
}(); }();
@@ -1380,7 +1382,7 @@ void cmNinjaTargetGenerator::ExportObjectCompileCommand(
this->GetMakefile()->GetRequiredDefinition(cmdVar); this->GetMakefile()->GetRequiredDefinition(cmdVar);
cmExpandList(compileCmd, compileCmds); cmExpandList(compileCmd, compileCmds);
} else { } else {
const std::string cmdVar = "CMAKE_" + language + "_COMPILE_OBJECT"; const std::string cmdVar = cmStrCat("CMAKE_", language, "_COMPILE_OBJECT");
const std::string& compileCmd = const std::string& compileCmd =
this->GetMakefile()->GetRequiredDefinition(cmdVar); this->GetMakefile()->GetRequiredDefinition(cmdVar);
cmExpandList(compileCmd, compileCmds); cmExpandList(compileCmd, compileCmds);