summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Source/cmLocalGenerator.cxx15
-rw-r--r--Source/cmLocalGenerator.h15
-rw-r--r--Source/cmLocalNinjaGenerator.cxx10
-rw-r--r--Source/cmLocalNinjaGenerator.h6
-rw-r--r--Source/cmLocalUnixMakefileGenerator3.cxx6
-rw-r--r--Source/cmMakefileExecutableTargetGenerator.cxx11
-rw-r--r--Source/cmMakefileLibraryTargetGenerator.cxx16
-rw-r--r--Source/cmNinjaNormalTargetGenerator.cxx10
-rw-r--r--Source/cmNinjaTargetGenerator.cxx12
9 files changed, 57 insertions, 44 deletions
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index 3b19694..138fe55 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -767,10 +767,6 @@ std::string cmLocalGenerator::ExpandRuleVariable(
void cmLocalGenerator::ExpandRuleVariables(std::string& s,
const RuleVariables& replaceValues)
{
- if (replaceValues.RuleLauncher) {
- this->InsertRuleLauncher(s, replaceValues.CMTarget,
- replaceValues.RuleLauncher);
- }
std::string::size_type start = s.find('<');
// no variables to expand
if (start == s.npos) {
@@ -814,17 +810,6 @@ const char* cmLocalGenerator::GetRuleLauncher(cmGeneratorTarget* target,
return this->Makefile->GetProperty(prop);
}
-void cmLocalGenerator::InsertRuleLauncher(std::string& s,
- cmGeneratorTarget* target,
- const std::string& prop)
-{
- if (const char* val = this->GetRuleLauncher(target, prop)) {
- std::ostringstream wrapped;
- wrapped << val << " " << s;
- s = wrapped.str();
- }
-}
-
std::string cmLocalGenerator::ConvertToIncludeReference(
std::string const& path, OutputFormat format, bool forceFullPaths)
{
diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h
index 69c4101..44d10bb 100644
--- a/Source/cmLocalGenerator.h
+++ b/Source/cmLocalGenerator.h
@@ -346,6 +346,13 @@ public:
void CreateEvaluationFileOutputs(const std::string& config);
void ProcessEvaluationFiles(std::vector<std::string>& generatedFiles);
+ // Expand rule variables in CMake of the type found in language rules
+ void ExpandRuleVariables(std::string& string,
+ const RuleVariables& replaceValues);
+
+ const char* GetRuleLauncher(cmGeneratorTarget* target,
+ const std::string& prop);
+
protected:
///! put all the libraries for a target on into the given stream
void OutputLinkLibraries(cmComputeLinkInformation* pcli,
@@ -353,18 +360,10 @@ protected:
std::string& linkLibraries,
std::string& frameworkPath, std::string& linkPath);
- // Expand rule variables in CMake of the type found in language rules
- void ExpandRuleVariables(std::string& string,
- const RuleVariables& replaceValues);
// Expand rule variables in a single string
std::string ExpandRuleVariable(std::string const& variable,
const RuleVariables& replaceValues);
- const char* GetRuleLauncher(cmGeneratorTarget* target,
- const std::string& prop);
- void InsertRuleLauncher(std::string& s, cmGeneratorTarget* target,
- const std::string& prop);
-
// Handle old-style install rules stored in the targets.
void GenerateTargetInstallRules(
std::ostream& os, const std::string& config,
diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx
index e25eb0f..ea711c0 100644
--- a/Source/cmLocalNinjaGenerator.cxx
+++ b/Source/cmLocalNinjaGenerator.cxx
@@ -468,8 +468,8 @@ void cmLocalNinjaGenerator::WriteCustomCommandBuildStatements()
std::string cmLocalNinjaGenerator::MakeCustomLauncher(
cmCustomCommandGenerator const& ccg)
{
- const char* property = "RULE_LAUNCH_CUSTOM";
- const char* property_value = this->Makefile->GetProperty(property);
+ const char* property_value =
+ this->Makefile->GetProperty("RULE_LAUNCH_CUSTOM");
if (!property_value || !*property_value) {
return std::string();
@@ -478,7 +478,7 @@ std::string cmLocalNinjaGenerator::MakeCustomLauncher(
// Expand rules in the empty string. It may insert the launcher and
// perform replacements.
RuleVariables vars;
- vars.RuleLauncher = property;
+
std::string output;
const std::vector<std::string>& outputs = ccg.GetOutputs();
if (!outputs.empty()) {
@@ -491,7 +491,9 @@ std::string cmLocalNinjaGenerator::MakeCustomLauncher(
}
vars.Output = output.c_str();
- std::string launcher;
+ std::string launcher = property_value;
+ launcher += " ";
+
this->ExpandRuleVariables(launcher, vars);
if (!launcher.empty()) {
launcher += " ";
diff --git a/Source/cmLocalNinjaGenerator.h b/Source/cmLocalNinjaGenerator.h
index b04788d..56aa9bf 100644
--- a/Source/cmLocalNinjaGenerator.h
+++ b/Source/cmLocalNinjaGenerator.h
@@ -58,12 +58,6 @@ public:
return this->HomeRelativeOutputPath;
}
- void ExpandRuleVariables(std::string& string,
- const RuleVariables& replaceValues)
- {
- cmLocalGenerator::ExpandRuleVariables(string, replaceValues);
- }
-
std::string BuildCommandLine(const std::vector<std::string>& cmdLines);
void AppendTargetOutputs(cmGeneratorTarget* target, cmNinjaDeps& outputs);
diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx
index 02eef59..92b58ba 100644
--- a/Source/cmLocalUnixMakefileGenerator3.cxx
+++ b/Source/cmLocalUnixMakefileGenerator3.cxx
@@ -984,13 +984,11 @@ void cmLocalUnixMakefileGenerator3::AppendCustomCommand(
std::string launcher;
// Short-circuit if there is no launcher.
- const char* prop = "RULE_LAUNCH_CUSTOM";
- const char* val = this->GetRuleLauncher(target, prop);
+ const char* val = this->GetRuleLauncher(target, "RULE_LAUNCH_CUSTOM");
if (val && *val) {
// Expand rules in the empty string. It may insert the launcher and
// perform replacements.
RuleVariables vars;
- vars.RuleLauncher = prop;
vars.CMTarget = target;
std::string output;
const std::vector<std::string>& outputs = ccg.GetOutputs();
@@ -1005,6 +1003,8 @@ void cmLocalUnixMakefileGenerator3::AppendCustomCommand(
}
vars.Output = output.c_str();
+ launcher = val;
+ launcher += " ";
this->ExpandRuleVariables(launcher, vars);
if (!launcher.empty()) {
launcher += " ";
diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx
index ed34ce6..da29b60 100644
--- a/Source/cmMakefileExecutableTargetGenerator.cxx
+++ b/Source/cmMakefileExecutableTargetGenerator.cxx
@@ -332,7 +332,6 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
std::string manifests = this->GetManifests();
cmLocalGenerator::RuleVariables vars;
- vars.RuleLauncher = "RULE_LAUNCH_LINK";
vars.CMTarget = this->GeneratorTarget;
vars.Language = linkLanguage.c_str();
vars.Objects = buildObjs.c_str();
@@ -383,10 +382,20 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
real_link_commands.push_back(cmakeCommand);
}
+ std::string launcher;
+
+ const char* val = this->LocalGenerator->GetRuleLauncher(
+ this->GeneratorTarget, "RULE_LAUNCH_LINK");
+ if (val && *val) {
+ launcher = val;
+ launcher += " ";
+ }
+
// Expand placeholders in the commands.
this->LocalGenerator->TargetImplib = targetOutPathImport;
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->TargetImplib = "";
diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx
index a19d70e..5700c62 100644
--- a/Source/cmMakefileLibraryTargetGenerator.cxx
+++ b/Source/cmMakefileLibraryTargetGenerator.cxx
@@ -540,7 +540,6 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules(
vars.TargetVersionMajor = targetVersionMajor.c_str();
vars.TargetVersionMinor = targetVersionMinor.c_str();
- vars.RuleLauncher = "RULE_LAUNCH_LINK";
vars.CMTarget = this->GeneratorTarget;
vars.Language = linkLanguage.c_str();
vars.Objects = buildObjs.c_str();
@@ -597,6 +596,14 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules(
vars.LanguageCompileFlags = langFlags.c_str();
+ std::string launcher;
+ const char* val = this->LocalGenerator->GetRuleLauncher(
+ this->GeneratorTarget, "RULE_LAUNCH_LINK");
+ if (val && *val) {
+ launcher = val;
+ launcher += " ";
+ }
+
// Construct the main link rule and expand placeholders.
this->LocalGenerator->TargetImplib = targetOutPathImport;
if (useArchiveRules) {
@@ -611,7 +618,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules(
for (std::vector<std::string>::const_iterator i =
archiveCreateCommands.begin();
i != archiveCreateCommands.end(); ++i) {
- std::string cmd = *i;
+ std::string cmd = launcher + *i;
this->LocalGenerator->ExpandRuleVariables(cmd, vars);
real_link_commands.push_back(cmd);
}
@@ -622,7 +629,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules(
for (std::vector<std::string>::const_iterator i =
archiveAppendCommands.begin();
i != archiveAppendCommands.end(); ++i) {
- std::string cmd = *i;
+ std::string cmd = launcher + *i;
this->LocalGenerator->ExpandRuleVariables(cmd, vars);
real_link_commands.push_back(cmd);
}
@@ -632,7 +639,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules(
for (std::vector<std::string>::const_iterator i =
archiveFinishCommands.begin();
i != archiveFinishCommands.end(); ++i) {
- std::string cmd = *i;
+ std::string cmd = launcher + *i;
this->LocalGenerator->ExpandRuleVariables(cmd, vars);
// If there is no ranlib the command will be ":". Skip it.
if (!cmd.empty() && cmd[0] != ':') {
@@ -655,6 +662,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules(
// Expand placeholders.
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);
}
}
diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx
index d729114..64c434a 100644
--- a/Source/cmNinjaNormalTargetGenerator.cxx
+++ b/Source/cmNinjaNormalTargetGenerator.cxx
@@ -168,7 +168,6 @@ void cmNinjaNormalTargetGenerator::WriteLinkRule(bool useResponseFile)
if (!this->GetGlobalGenerator()->HasRule(ruleName)) {
cmLocalGenerator::RuleVariables vars;
- vars.RuleLauncher = "RULE_LAUNCH_LINK";
vars.CMTarget = this->GetGeneratorTarget();
vars.Language = this->TargetLinkLanguage.c_str();
@@ -238,10 +237,19 @@ void cmNinjaNormalTargetGenerator::WriteLinkRule(bool useResponseFile)
vars.LanguageCompileFlags = langFlags.c_str();
}
+ std::string launcher;
+ const char* val = this->GetLocalGenerator()->GetRuleLauncher(
+ this->GetGeneratorTarget(), "RULE_LAUNCH_LINK");
+ if (val && *val) {
+ launcher = val;
+ launcher += " ";
+ }
+
// Rule for linking library/executable.
std::vector<std::string> linkCmds = this->ComputeLinkCmd();
for (std::vector<std::string>::iterator i = linkCmds.begin();
i != linkCmds.end(); ++i) {
+ *i = launcher + *i;
this->GetLocalGenerator()->ExpandRuleVariables(*i, vars);
}
{
diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx
index 46a6161..f85ea81 100644
--- a/Source/cmNinjaTargetGenerator.cxx
+++ b/Source/cmNinjaTargetGenerator.cxx
@@ -374,7 +374,6 @@ void cmNinjaTargetGenerator::WriteLanguageRules(const std::string& language)
void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang)
{
cmLocalGenerator::RuleVariables vars;
- vars.RuleLauncher = "RULE_LAUNCH_COMPILE";
vars.CMTarget = this->GetGeneratorTarget();
vars.Language = lang.c_str();
vars.Source = "$IN_ABS";
@@ -456,6 +455,14 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang)
ConvertToNinjaPath(this->GetTargetDependInfoPath(lang)),
cmLocalGenerator::SHELL);
+ std::string launcher;
+ const char* val = this->GetLocalGenerator()->GetRuleLauncher(
+ this->GetGeneratorTarget(), "RULE_LAUNCH_COMPILE");
+ if (val && *val) {
+ launcher = val;
+ launcher += " ";
+ }
+
if (explicitPP) {
// Lookup the explicit preprocessing rule.
std::string const ppVar = "CMAKE_" + lang + "_PREPROCESS_SOURCE";
@@ -467,7 +474,6 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang)
std::string const ppDepfile = "$DEP_FILE";
cmLocalGenerator::RuleVariables ppVars;
- ppVars.RuleLauncher = vars.RuleLauncher;
ppVars.CMTarget = vars.CMTarget;
ppVars.Language = vars.Language;
ppVars.Object = "$out"; // for RULE_LAUNCH_COMPILE
@@ -496,6 +502,7 @@ 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);
}
@@ -608,6 +615,7 @@ 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);
}