mirror of
https://github.com/Kitware/CMake.git
synced 2026-08-10 01:28:02 +00:00
cmNinjaTargetGenerator: Factor out helper for shell path arguments
This commit is contained in:
@@ -517,6 +517,13 @@ std::string cmNinjaTargetGenerator::GetTargetName() const
|
||||
return this->GeneratorTarget->GetName();
|
||||
}
|
||||
|
||||
std::string cmNinjaTargetGenerator::ConvertToOutputFormatForShell(
|
||||
cm::string_view path) const
|
||||
{
|
||||
return this->LocalGenerator->ConvertToOutputFormat(path,
|
||||
cmOutputConverter::SHELL);
|
||||
}
|
||||
|
||||
bool cmNinjaTargetGenerator::SetMsvcTargetPdbVariable(
|
||||
cmNinjaVars& vars, std::string const& config) const
|
||||
{
|
||||
@@ -534,11 +541,10 @@ bool cmNinjaTargetGenerator::SetMsvcTargetPdbVariable(
|
||||
this->GeneratorTarget->GetPDBName(config));
|
||||
}
|
||||
|
||||
vars["TARGET_PDB"] = this->GetLocalGenerator()->ConvertToOutputFormat(
|
||||
this->ConvertToNinjaPath(pdbPath), cmOutputConverter::SHELL);
|
||||
vars["TARGET_COMPILE_PDB"] =
|
||||
this->GetLocalGenerator()->ConvertToOutputFormat(
|
||||
this->ConvertToNinjaPath(compilePdbPath), cmOutputConverter::SHELL);
|
||||
vars["TARGET_PDB"] =
|
||||
this->ConvertToOutputFormatForShell(this->ConvertToNinjaPath(pdbPath));
|
||||
vars["TARGET_COMPILE_PDB"] = this->ConvertToOutputFormatForShell(
|
||||
this->ConvertToNinjaPath(compilePdbPath));
|
||||
|
||||
this->EnsureParentDirectoryExists(pdbPath);
|
||||
this->EnsureParentDirectoryExists(compilePdbPath);
|
||||
@@ -693,9 +699,8 @@ void cmNinjaTargetGenerator::WriteCompileRule(std::string const& lang,
|
||||
auto rulePlaceholderExpander =
|
||||
this->GetLocalGenerator()->CreateRulePlaceholderExpander();
|
||||
|
||||
std::string const tdi = this->GetLocalGenerator()->ConvertToOutputFormat(
|
||||
this->ConvertToNinjaPath(this->GetTargetDependInfoPath(lang, config)),
|
||||
cmLocalGenerator::SHELL);
|
||||
std::string const tdi = this->ConvertToOutputFormatForShell(
|
||||
this->ConvertToNinjaPath(this->GetTargetDependInfoPath(lang, config)));
|
||||
|
||||
std::string launcher;
|
||||
std::string val = this->GetLocalGenerator()->GetRuleLauncher(
|
||||
@@ -705,8 +710,7 @@ void cmNinjaTargetGenerator::WriteCompileRule(std::string const& lang,
|
||||
}
|
||||
|
||||
std::string const cmakeCmd =
|
||||
this->GetLocalGenerator()->ConvertToOutputFormat(
|
||||
cmSystemTools::GetCMakeCommand(), cmLocalGenerator::SHELL);
|
||||
this->ConvertToOutputFormatForShell(cmSystemTools::GetCMakeCommand());
|
||||
|
||||
if (withScanning == WithScanning::Yes) {
|
||||
auto const& scanDepType = this->GetMakefile()->GetSafeDefinition(
|
||||
@@ -1298,8 +1302,7 @@ void cmNinjaTargetGenerator::GenerateSwiftOutputFileMap(
|
||||
this->LocalGenerator->AppendFlags(flags, "-output-file-map");
|
||||
this->LocalGenerator->AppendFlags(
|
||||
flags,
|
||||
this->GetLocalGenerator()->ConvertToOutputFormat(
|
||||
ConvertToNinjaPath(mapFilePath), cmOutputConverter::SHELL));
|
||||
this->ConvertToOutputFormatForShell(ConvertToNinjaPath(mapFilePath)));
|
||||
}
|
||||
|
||||
namespace {
|
||||
@@ -1442,8 +1445,8 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatement(
|
||||
: this->GetGeneratorTarget()->GetPropertyAsBool("SKIP_LINTING");
|
||||
|
||||
if (!skipCodeCheck) {
|
||||
auto const cmakeCmd = this->GetLocalGenerator()->ConvertToOutputFormat(
|
||||
cmSystemTools::GetCMakeCommand(), cmLocalGenerator::SHELL);
|
||||
auto const cmakeCmd =
|
||||
this->ConvertToOutputFormatForShell(cmSystemTools::GetCMakeCommand());
|
||||
vars["CODE_CHECK"] =
|
||||
this->GenerateCodeCheckRules(*source, compilerLauncher, cmakeCmd, config,
|
||||
[this](std::string const& path) {
|
||||
@@ -1659,13 +1662,10 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatement(
|
||||
|
||||
this->EnsureParentDirectoryExists(objectFileName);
|
||||
|
||||
vars["OBJECT_DIR"] = this->GetLocalGenerator()->ConvertToOutputFormat(
|
||||
objectDir, cmOutputConverter::SHELL);
|
||||
vars["OBJECT_DIR"] = this->ConvertToOutputFormatForShell(objectDir);
|
||||
vars["TARGET_SUPPORT_DIR"] =
|
||||
this->GetLocalGenerator()->ConvertToOutputFormat(targetSupportDir,
|
||||
cmOutputConverter::SHELL);
|
||||
vars["OBJECT_FILE_DIR"] = this->GetLocalGenerator()->ConvertToOutputFormat(
|
||||
objectFileDir, cmOutputConverter::SHELL);
|
||||
this->ConvertToOutputFormatForShell(targetSupportDir);
|
||||
vars["OBJECT_FILE_DIR"] = this->ConvertToOutputFormatForShell(objectFileDir);
|
||||
|
||||
this->addPoolNinjaVariable("JOB_POOL_COMPILE", this->GetGeneratorTarget(),
|
||||
source, vars);
|
||||
@@ -1724,9 +1724,7 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatement(
|
||||
}
|
||||
}
|
||||
|
||||
vars["ISPC_HEADER_FILE"] =
|
||||
this->GetLocalGenerator()->ConvertToOutputFormat(
|
||||
ispcHeader, cmOutputConverter::SHELL);
|
||||
vars["ISPC_HEADER_FILE"] = this->ConvertToOutputFormatForShell(ispcHeader);
|
||||
} else {
|
||||
auto headers = this->GeneratorTarget->GetGeneratedISPCHeaders(config);
|
||||
if (!headers.empty()) {
|
||||
@@ -1890,13 +1888,10 @@ void cmNinjaTargetGenerator::WriteCxxModuleBmiBuildStatement(
|
||||
|
||||
this->EnsureParentDirectoryExists(bmiFileName);
|
||||
|
||||
vars["OBJECT_DIR"] = this->GetLocalGenerator()->ConvertToOutputFormat(
|
||||
bmiDir, cmOutputConverter::SHELL);
|
||||
vars["OBJECT_DIR"] = this->ConvertToOutputFormatForShell(bmiDir);
|
||||
vars["TARGET_SUPPORT_DIR"] =
|
||||
this->GetLocalGenerator()->ConvertToOutputFormat(targetSupportDir,
|
||||
cmOutputConverter::SHELL);
|
||||
vars["OBJECT_FILE_DIR"] = this->GetLocalGenerator()->ConvertToOutputFormat(
|
||||
bmiFileDir, cmOutputConverter::SHELL);
|
||||
this->ConvertToOutputFormatForShell(targetSupportDir);
|
||||
vars["OBJECT_FILE_DIR"] = this->ConvertToOutputFormatForShell(bmiFileDir);
|
||||
|
||||
this->addPoolNinjaVariable("JOB_POOL_COMPILE", this->GetGeneratorTarget(),
|
||||
source, vars);
|
||||
@@ -2530,9 +2525,7 @@ void cmNinjaTargetGenerator::MacOSXContentGeneratorType::operator()(
|
||||
void cmNinjaTargetGenerator::AddDepfileBinding(cmNinjaVars& vars,
|
||||
std::string depfile) const
|
||||
{
|
||||
std::string depfileForShell =
|
||||
this->GetLocalGenerator()->ConvertToOutputFormat(depfile,
|
||||
cmOutputConverter::SHELL);
|
||||
std::string depfileForShell = this->ConvertToOutputFormatForShell(depfile);
|
||||
if (depfile != depfileForShell) {
|
||||
vars["depfile"] = std::move(depfile);
|
||||
}
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include <cm/string_view>
|
||||
|
||||
#include <cm3p/json/value.h>
|
||||
|
||||
#include "cmCommonTargetGenerator.h"
|
||||
@@ -42,6 +44,8 @@ public:
|
||||
|
||||
std::string GetTargetName() const;
|
||||
|
||||
std::string ConvertToOutputFormatForShell(cm::string_view path) const;
|
||||
|
||||
void AddDepfileBinding(cmNinjaVars& vars, std::string depfile) const;
|
||||
void RemoveDepfileBinding(cmNinjaVars& vars) const;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user