summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorStephen Kelly <steveire@gmail.com>2016-10-09 08:34:50 (GMT)
committerStephen Kelly <steveire@gmail.com>2016-10-15 09:25:12 (GMT)
commit46ad0d2183230d1af93242efbdcce20d55514efb (patch)
treed850f9a4d42df6e5bc39c8d01234051fd6ca7f29 /Source
parent2628dec12cb22546d2a21032f53fb0ef096faec8 (diff)
downloadCMake-46ad0d2183230d1af93242efbdcce20d55514efb.zip
CMake-46ad0d2183230d1af93242efbdcce20d55514efb.tar.gz
CMake-46ad0d2183230d1af93242efbdcce20d55514efb.tar.bz2
cmLocalGenerator: Use a converter in rule replacement API
The rule replacement API should not really be in cmLocalGenerator, but it was historically, and this coupled many other things together here too, such as output conversion. Make the output converter a parameter so that rule replacement can be removed from cmLocalGenerator.
Diffstat (limited to 'Source')
-rw-r--r--Source/cmLocalGenerator.cxx17
-rw-r--r--Source/cmLocalGenerator.h6
-rw-r--r--Source/cmLocalNinjaGenerator.cxx2
-rw-r--r--Source/cmLocalUnixMakefileGenerator3.cxx2
-rw-r--r--Source/cmMakefileExecutableTargetGenerator.cxx3
-rw-r--r--Source/cmMakefileLibraryTargetGenerator.cxx12
-rw-r--r--Source/cmMakefileTargetGenerator.cxx12
-rw-r--r--Source/cmNinjaNormalTargetGenerator.cxx3
-rw-r--r--Source/cmNinjaTargetGenerator.cxx9
9 files changed, 42 insertions, 24 deletions
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index 42e4b63..6dd90c8 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -561,7 +561,8 @@ cmState::Snapshot cmLocalGenerator::GetStateSnapshot() const
}
std::string cmLocalGenerator::ExpandRuleVariable(
- std::string const& variable, const RuleVariables& replaceValues)
+ cmOutputConverter* outputConverter, std::string const& variable,
+ const RuleVariables& replaceValues)
{
if (replaceValues.LinkFlags) {
if (variable == "LINK_FLAGS") {
@@ -737,7 +738,7 @@ std::string cmLocalGenerator::ExpandRuleVariable(
}
}
if (variable == "CMAKE_COMMAND") {
- return this->ConvertToOutputFormat(
+ return outputConverter->ConvertToOutputFormat(
cmSystemTools::CollapseFullPath(cmSystemTools::GetCMakeCommand()),
SHELL);
}
@@ -780,12 +781,12 @@ std::string cmLocalGenerator::ExpandRuleVariable(
!compilerOptionExternalToolchain.empty()) {
ret += " ";
ret += compilerOptionExternalToolchain;
- ret += this->EscapeForShell(compilerExternalToolchain, true);
+ ret += outputConverter->EscapeForShell(compilerExternalToolchain, true);
}
if (!this->CompilerSysroot.empty() && !compilerOptionSysroot.empty()) {
ret += " ";
ret += compilerOptionSysroot;
- ret += this->EscapeForShell(this->CompilerSysroot, true);
+ ret += outputConverter->EscapeForShell(this->CompilerSysroot, true);
}
return ret;
}
@@ -794,14 +795,15 @@ std::string cmLocalGenerator::ExpandRuleVariable(
this->VariableMappings.find(variable);
if (mapIt != this->VariableMappings.end()) {
if (variable.find("_FLAG") == variable.npos) {
- return this->ConvertToOutputForExisting(mapIt->second);
+ return outputConverter->ConvertToOutputForExisting(mapIt->second);
}
return mapIt->second;
}
return variable;
}
-void cmLocalGenerator::ExpandRuleVariables(std::string& s,
+void cmLocalGenerator::ExpandRuleVariables(cmOutputConverter* outputConverter,
+ std::string& s,
const RuleVariables& replaceValues)
{
std::string::size_type start = s.find('<');
@@ -825,7 +827,8 @@ void cmLocalGenerator::ExpandRuleVariables(std::string& s,
} else {
// extract the var
std::string var = s.substr(start + 1, end - start - 1);
- std::string replace = this->ExpandRuleVariable(var, replaceValues);
+ std::string replace =
+ this->ExpandRuleVariable(outputConverter, var, replaceValues);
expandedInput += s.substr(pos, start - pos);
expandedInput += replace;
// move to next one
diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h
index d54fbff..7359f50 100644
--- a/Source/cmLocalGenerator.h
+++ b/Source/cmLocalGenerator.h
@@ -347,7 +347,8 @@ public:
void ProcessEvaluationFiles(std::vector<std::string>& generatedFiles);
// Expand rule variables in CMake of the type found in language rules
- void ExpandRuleVariables(std::string& string,
+ void ExpandRuleVariables(cmOutputConverter* outputConverter,
+ std::string& string,
const RuleVariables& replaceValues);
const char* GetRuleLauncher(cmGeneratorTarget* target,
@@ -361,7 +362,8 @@ protected:
std::string& frameworkPath, std::string& linkPath);
// Expand rule variables in a single string
- std::string ExpandRuleVariable(std::string const& variable,
+ std::string ExpandRuleVariable(cmOutputConverter* outputConverter,
+ std::string const& variable,
const RuleVariables& replaceValues);
// Handle old-style install rules stored in the targets.
diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx
index ea711c0..05596f8 100644
--- a/Source/cmLocalNinjaGenerator.cxx
+++ b/Source/cmLocalNinjaGenerator.cxx
@@ -494,7 +494,7 @@ std::string cmLocalNinjaGenerator::MakeCustomLauncher(
std::string launcher = property_value;
launcher += " ";
- this->ExpandRuleVariables(launcher, vars);
+ this->ExpandRuleVariables(this, launcher, vars);
if (!launcher.empty()) {
launcher += " ";
}
diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx
index 92b58ba..a4c73dd 100644
--- a/Source/cmLocalUnixMakefileGenerator3.cxx
+++ b/Source/cmLocalUnixMakefileGenerator3.cxx
@@ -1005,7 +1005,7 @@ void cmLocalUnixMakefileGenerator3::AppendCustomCommand(
launcher = val;
launcher += " ";
- this->ExpandRuleVariables(launcher, vars);
+ this->ExpandRuleVariables(this, launcher, vars);
if (!launcher.empty()) {
launcher += " ";
}
diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx
index da29b60..92d6185 100644
--- a/Source/cmMakefileExecutableTargetGenerator.cxx
+++ b/Source/cmMakefileExecutableTargetGenerator.cxx
@@ -396,7 +396,8 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
for (std::vector<std::string>::iterator i = real_link_commands.begin();
i != real_link_commands.end(); ++i) {
*i = launcher + *i;
- this->LocalGenerator->ExpandRuleVariables(*i, vars);
+ this->LocalGenerator->ExpandRuleVariables(this->LocalGenerator, *i,
+ vars);
}
this->LocalGenerator->TargetImplib = "";
diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx
index 5700c62..0566c1b 100644
--- a/Source/cmMakefileLibraryTargetGenerator.cxx
+++ b/Source/cmMakefileLibraryTargetGenerator.cxx
@@ -619,7 +619,8 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules(
archiveCreateCommands.begin();
i != archiveCreateCommands.end(); ++i) {
std::string cmd = launcher + *i;
- this->LocalGenerator->ExpandRuleVariables(cmd, vars);
+ this->LocalGenerator->ExpandRuleVariables(this->LocalGenerator, cmd,
+ vars);
real_link_commands.push_back(cmd);
}
}
@@ -630,7 +631,8 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules(
archiveAppendCommands.begin();
i != archiveAppendCommands.end(); ++i) {
std::string cmd = launcher + *i;
- this->LocalGenerator->ExpandRuleVariables(cmd, vars);
+ this->LocalGenerator->ExpandRuleVariables(this->LocalGenerator, cmd,
+ vars);
real_link_commands.push_back(cmd);
}
}
@@ -640,7 +642,8 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules(
archiveFinishCommands.begin();
i != archiveFinishCommands.end(); ++i) {
std::string cmd = launcher + *i;
- this->LocalGenerator->ExpandRuleVariables(cmd, vars);
+ this->LocalGenerator->ExpandRuleVariables(this->LocalGenerator, cmd,
+ vars);
// If there is no ranlib the command will be ":". Skip it.
if (!cmd.empty() && cmd[0] != ':') {
real_link_commands.push_back(cmd);
@@ -663,7 +666,8 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules(
for (std::vector<std::string>::iterator i = real_link_commands.begin();
i != real_link_commands.end(); ++i) {
*i = launcher + *i;
- this->LocalGenerator->ExpandRuleVariables(*i, vars);
+ this->LocalGenerator->ExpandRuleVariables(this->LocalGenerator, *i,
+ vars);
}
}
this->LocalGenerator->TargetImplib = "";
diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx
index 84ae726..77643d1 100644
--- a/Source/cmMakefileTargetGenerator.cxx
+++ b/Source/cmMakefileTargetGenerator.cxx
@@ -600,7 +600,8 @@ void cmMakefileTargetGenerator::WriteObjectBuildFile(
if (this->Makefile->IsOn("CMAKE_EXPORT_COMPILE_COMMANDS") &&
lang_can_export_cmds && compileCommands.size() == 1) {
std::string compileCommand = compileCommands[0];
- this->LocalGenerator->ExpandRuleVariables(compileCommand, vars);
+ this->LocalGenerator->ExpandRuleVariables(this->LocalGenerator,
+ compileCommand, vars);
std::string workingDirectory = cmSystemTools::CollapseFullPath(
this->LocalGenerator->GetCurrentBinaryDirectory());
compileCommand.replace(compileCommand.find(langFlags), langFlags.size(),
@@ -659,7 +660,8 @@ void cmMakefileTargetGenerator::WriteObjectBuildFile(
// Expand placeholders in the commands.
for (std::vector<std::string>::iterator i = compileCommands.begin();
i != compileCommands.end(); ++i) {
- this->LocalGenerator->ExpandRuleVariables(*i, vars);
+ this->LocalGenerator->ExpandRuleVariables(this->LocalGenerator, *i,
+ vars);
}
// Change the command working directory to the local build tree.
@@ -722,7 +724,8 @@ void cmMakefileTargetGenerator::WriteObjectBuildFile(
// Expand placeholders in the commands.
for (std::vector<std::string>::iterator i = preprocessCommands.begin();
i != preprocessCommands.end(); ++i) {
- this->LocalGenerator->ExpandRuleVariables(*i, vars);
+ this->LocalGenerator->ExpandRuleVariables(this->LocalGenerator, *i,
+ vars);
}
this->LocalGenerator->CreateCDCommand(
@@ -769,7 +772,8 @@ void cmMakefileTargetGenerator::WriteObjectBuildFile(
// Expand placeholders in the commands.
for (std::vector<std::string>::iterator i = assemblyCommands.begin();
i != assemblyCommands.end(); ++i) {
- this->LocalGenerator->ExpandRuleVariables(*i, vars);
+ this->LocalGenerator->ExpandRuleVariables(this->LocalGenerator, *i,
+ vars);
}
this->LocalGenerator->CreateCDCommand(
diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx
index 64c434a..154f3c3 100644
--- a/Source/cmNinjaNormalTargetGenerator.cxx
+++ b/Source/cmNinjaNormalTargetGenerator.cxx
@@ -250,7 +250,8 @@ void cmNinjaNormalTargetGenerator::WriteLinkRule(bool useResponseFile)
for (std::vector<std::string>::iterator i = linkCmds.begin();
i != linkCmds.end(); ++i) {
*i = launcher + *i;
- this->GetLocalGenerator()->ExpandRuleVariables(*i, vars);
+ this->GetLocalGenerator()->ExpandRuleVariables(this->GetLocalGenerator(),
+ *i, vars);
}
{
// If there is no ranlib the command will be ":". Skip it.
diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx
index f85ea81..8ae055f 100644
--- a/Source/cmNinjaTargetGenerator.cxx
+++ b/Source/cmNinjaTargetGenerator.cxx
@@ -503,7 +503,8 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang)
for (std::vector<std::string>::iterator i = ppCmds.begin();
i != ppCmds.end(); ++i) {
*i = launcher + *i;
- this->GetLocalGenerator()->ExpandRuleVariables(*i, ppVars);
+ this->GetLocalGenerator()->ExpandRuleVariables(this->GetLocalGenerator(),
+ *i, ppVars);
}
// Run CMake dependency scanner on preprocessed output.
@@ -616,7 +617,8 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang)
for (std::vector<std::string>::iterator i = compileCmds.begin();
i != compileCmds.end(); ++i) {
*i = launcher + *i;
- this->GetLocalGenerator()->ExpandRuleVariables(*i, vars);
+ this->GetLocalGenerator()->ExpandRuleVariables(this->GetLocalGenerator(),
+ *i, vars);
}
std::string cmdLine =
@@ -1003,7 +1005,8 @@ void cmNinjaTargetGenerator::ExportObjectCompileCommand(
for (std::vector<std::string>::iterator i = compileCmds.begin();
i != compileCmds.end(); ++i) {
- this->GetLocalGenerator()->ExpandRuleVariables(*i, compileObjectVars);
+ this->GetLocalGenerator()->ExpandRuleVariables(this->GetLocalGenerator(),
+ *i, compileObjectVars);
}
std::string cmdLine =