ENH: Define RULE_LAUNCH_* properties
This defines global, directory, and target properties RULE_LAUNCH_COMPILE, RULE_LAUNCH_LINK, and RULE_LAUNCH_CUSTOM. Their values specify 'launcher' command lines which are prefixed to compile, link, and custom build rules by Makefile generators.
This commit is contained in:
parent
c895d9f2e0
commit
b604b98c56
@ -50,6 +50,7 @@ IF(NOT _CTEST_TARGETS_ADDED)
|
|||||||
ADD_CUSTOM_TARGET(${mode}
|
ADD_CUSTOM_TARGET(${mode}
|
||||||
${CMAKE_CTEST_COMMAND} ${__conf_types} -D ${mode}
|
${CMAKE_CTEST_COMMAND} ${__conf_types} -D ${mode}
|
||||||
)
|
)
|
||||||
|
SET_PROPERTY(TARGET ${mode} PROPERTY RULE_LAUNCH_CUSTOM "")
|
||||||
ENDFOREACH(mode)
|
ENDFOREACH(mode)
|
||||||
|
|
||||||
# For Makefile generators add more granular targets.
|
# For Makefile generators add more granular targets.
|
||||||
@ -63,6 +64,7 @@ IF(NOT _CTEST_TARGETS_ADDED)
|
|||||||
ADD_CUSTOM_TARGET(${mode}${testtype}
|
ADD_CUSTOM_TARGET(${mode}${testtype}
|
||||||
${CMAKE_CTEST_COMMAND} ${__conf_types} -D ${mode}${testtype}
|
${CMAKE_CTEST_COMMAND} ${__conf_types} -D ${mode}${testtype}
|
||||||
)
|
)
|
||||||
|
SET_PROPERTY(TARGET ${mode}${testtype} PROPERTY RULE_LAUNCH_CUSTOM "")
|
||||||
ENDFOREACH(testtype)
|
ENDFOREACH(testtype)
|
||||||
ENDFOREACH(mode)
|
ENDFOREACH(mode)
|
||||||
ENDIF("${CMAKE_GENERATOR}" MATCHES Make)
|
ENDIF("${CMAKE_GENERATOR}" MATCHES Make)
|
||||||
|
@ -1034,6 +1034,8 @@ cmLocalGenerator::ExpandRuleVariables(std::string& s,
|
|||||||
{
|
{
|
||||||
std::vector<std::string> enabledLanguages;
|
std::vector<std::string> enabledLanguages;
|
||||||
this->GlobalGenerator->GetEnabledLanguages(enabledLanguages);
|
this->GlobalGenerator->GetEnabledLanguages(enabledLanguages);
|
||||||
|
this->InsertRuleLauncher(s, replaceValues.CMTarget,
|
||||||
|
replaceValues.RuleLauncher);
|
||||||
std::string::size_type start = s.find('<');
|
std::string::size_type start = s.find('<');
|
||||||
// no variables to expand
|
// no variables to expand
|
||||||
if(start == s.npos)
|
if(start == s.npos)
|
||||||
@ -1075,6 +1077,32 @@ cmLocalGenerator::ExpandRuleVariables(std::string& s,
|
|||||||
s = expandedInput;
|
s = expandedInput;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
const char* cmLocalGenerator::GetRuleLauncher(cmTarget* target,
|
||||||
|
const char* prop)
|
||||||
|
{
|
||||||
|
if(target)
|
||||||
|
{
|
||||||
|
return target->GetProperty(prop);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return this->Makefile->GetProperty(prop);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
void cmLocalGenerator::InsertRuleLauncher(std::string& s, cmTarget* target,
|
||||||
|
const char* prop)
|
||||||
|
{
|
||||||
|
if(const char* val = this->GetRuleLauncher(target, prop))
|
||||||
|
{
|
||||||
|
cmOStringStream wrapped;
|
||||||
|
wrapped << val << " " << s;
|
||||||
|
s = wrapped.str();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
std::string
|
std::string
|
||||||
cmLocalGenerator::ConvertToOutputForExistingCommon(const char* remote,
|
cmLocalGenerator::ConvertToOutputForExistingCommon(const char* remote,
|
||||||
|
@ -203,6 +203,7 @@ public:
|
|||||||
{
|
{
|
||||||
memset(this, 0, sizeof(*this));
|
memset(this, 0, sizeof(*this));
|
||||||
}
|
}
|
||||||
|
cmTarget* CMTarget;
|
||||||
const char* TargetPDB;
|
const char* TargetPDB;
|
||||||
const char* TargetVersionMajor;
|
const char* TargetVersionMajor;
|
||||||
const char* TargetVersionMinor;
|
const char* TargetVersionMinor;
|
||||||
@ -222,6 +223,7 @@ public:
|
|||||||
const char* LinkFlags;
|
const char* LinkFlags;
|
||||||
const char* LanguageCompileFlags;
|
const char* LanguageCompileFlags;
|
||||||
const char* Defines;
|
const char* Defines;
|
||||||
|
const char* RuleLauncher;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Set whether to treat conversions to SHELL as a link script shell. */
|
/** Set whether to treat conversions to SHELL as a link script shell. */
|
||||||
@ -317,6 +319,11 @@ protected:
|
|||||||
// Expand rule variables in a single string
|
// Expand rule variables in a single string
|
||||||
std::string ExpandRuleVariable(std::string const& variable,
|
std::string ExpandRuleVariable(std::string const& variable,
|
||||||
const RuleVariables& replaceValues);
|
const RuleVariables& replaceValues);
|
||||||
|
|
||||||
|
const char* GetRuleLauncher(cmTarget* target, const char* prop);
|
||||||
|
void InsertRuleLauncher(std::string& s, cmTarget* target,
|
||||||
|
const char* prop);
|
||||||
|
|
||||||
|
|
||||||
/** Convert a target to a utility target for unsupported
|
/** Convert a target to a utility target for unsupported
|
||||||
* languages of a generator */
|
* languages of a generator */
|
||||||
|
@ -974,7 +974,6 @@ cmLocalUnixMakefileGenerator3
|
|||||||
cmLocalGenerator::RelativeRoot relative,
|
cmLocalGenerator::RelativeRoot relative,
|
||||||
std::ostream* content)
|
std::ostream* content)
|
||||||
{
|
{
|
||||||
static_cast<void>(target); // Future use
|
|
||||||
// Optionally create a command to display the custom command's
|
// Optionally create a command to display the custom command's
|
||||||
// comment text. This is used for pre-build, pre-link, and
|
// comment text. This is used for pre-build, pre-link, and
|
||||||
// post-build command comments. Custom build step commands have
|
// post-build command comments. Custom build step commands have
|
||||||
@ -1043,7 +1042,9 @@ cmLocalUnixMakefileGenerator3
|
|||||||
cmd = scmd;
|
cmd = scmd;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cmd = this->Convert(cmd.c_str(),NONE,SHELL);
|
std::string launcher =
|
||||||
|
this->MakeLauncher(cc, target, workingDir? NONE : START_OUTPUT);
|
||||||
|
cmd = launcher + this->Convert(cmd.c_str(),NONE,SHELL);
|
||||||
for(unsigned int j=1; j < commandLine.size(); ++j)
|
for(unsigned int j=1; j < commandLine.size(); ++j)
|
||||||
{
|
{
|
||||||
cmd += " ";
|
cmd += " ";
|
||||||
@ -1059,7 +1060,8 @@ cmLocalUnixMakefileGenerator3
|
|||||||
}
|
}
|
||||||
if(content)
|
if(content)
|
||||||
{
|
{
|
||||||
*content << cmd;
|
// Rule content does not include the launcher.
|
||||||
|
*content << (cmd.c_str()+launcher.size());
|
||||||
}
|
}
|
||||||
if(this->BorlandMakeCurlyHack)
|
if(this->BorlandMakeCurlyHack)
|
||||||
{
|
{
|
||||||
@ -1093,6 +1095,35 @@ cmLocalUnixMakefileGenerator3
|
|||||||
commands.insert(commands.end(), commands1.begin(), commands1.end());
|
commands.insert(commands.end(), commands1.begin(), commands1.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
std::string
|
||||||
|
cmLocalUnixMakefileGenerator3::MakeLauncher(const cmCustomCommand& cc,
|
||||||
|
cmTarget* target,
|
||||||
|
RelativeRoot relative)
|
||||||
|
{
|
||||||
|
// Short-circuit if there is no launcher.
|
||||||
|
const char* prop = "RULE_LAUNCH_CUSTOM";
|
||||||
|
const char* val = this->GetRuleLauncher(target, prop);
|
||||||
|
if(!(val && *val))
|
||||||
|
{
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Expand rules in the empty string. It may insert the launcher and
|
||||||
|
// perform replacements.
|
||||||
|
RuleVariables vars;
|
||||||
|
vars.RuleLauncher = prop;
|
||||||
|
vars.CMTarget = target;
|
||||||
|
|
||||||
|
std::string launcher;
|
||||||
|
this->ExpandRuleVariables(launcher, vars);
|
||||||
|
if(!launcher.empty())
|
||||||
|
{
|
||||||
|
launcher += " ";
|
||||||
|
}
|
||||||
|
return launcher;
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
void
|
void
|
||||||
cmLocalUnixMakefileGenerator3
|
cmLocalUnixMakefileGenerator3
|
||||||
|
@ -347,6 +347,9 @@ protected:
|
|||||||
void CheckMultipleOutputs(bool verbose);
|
void CheckMultipleOutputs(bool verbose);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
std::string MakeLauncher(const cmCustomCommand& cc, cmTarget* target,
|
||||||
|
RelativeRoot relative);
|
||||||
|
|
||||||
friend class cmMakefileTargetGenerator;
|
friend class cmMakefileTargetGenerator;
|
||||||
friend class cmMakefileExecutableTargetGenerator;
|
friend class cmMakefileExecutableTargetGenerator;
|
||||||
friend class cmMakefileLibraryTargetGenerator;
|
friend class cmMakefileLibraryTargetGenerator;
|
||||||
|
@ -3564,6 +3564,25 @@ void cmMakefile::DefineProperties(cmake *cm)
|
|||||||
"This read-only property specifies the list of directories given "
|
"This read-only property specifies the list of directories given "
|
||||||
"so far to the link_directories command. "
|
"so far to the link_directories command. "
|
||||||
"It is intended for debugging purposes.", false);
|
"It is intended for debugging purposes.", false);
|
||||||
|
|
||||||
|
cm->DefineProperty
|
||||||
|
("RULE_LAUNCH_COMPILE", cmProperty::DIRECTORY,
|
||||||
|
"Specify a launcher for compile rules.",
|
||||||
|
"See the global property of the same name for details. "
|
||||||
|
"This overrides the global property for a directory.",
|
||||||
|
true);
|
||||||
|
cm->DefineProperty
|
||||||
|
("RULE_LAUNCH_LINK", cmProperty::DIRECTORY,
|
||||||
|
"Specify a launcher for link rules.",
|
||||||
|
"See the global property of the same name for details. "
|
||||||
|
"This overrides the global property for a directory.",
|
||||||
|
true);
|
||||||
|
cm->DefineProperty
|
||||||
|
("RULE_LAUNCH_CUSTOM", cmProperty::DIRECTORY,
|
||||||
|
"Specify a launcher for custom rules.",
|
||||||
|
"See the global property of the same name for details. "
|
||||||
|
"This overrides the global property for a directory.",
|
||||||
|
true);
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
|
@ -360,6 +360,8 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
|
|||||||
buildObjs, depends);
|
buildObjs, depends);
|
||||||
|
|
||||||
cmLocalGenerator::RuleVariables vars;
|
cmLocalGenerator::RuleVariables vars;
|
||||||
|
vars.RuleLauncher = "RULE_LAUNCH_LINK";
|
||||||
|
vars.CMTarget = this->Target;
|
||||||
vars.Language = linkLanguage;
|
vars.Language = linkLanguage;
|
||||||
vars.Objects = buildObjs.c_str();
|
vars.Objects = buildObjs.c_str();
|
||||||
vars.Target = targetOutPathReal.c_str();
|
vars.Target = targetOutPathReal.c_str();
|
||||||
|
@ -713,6 +713,8 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
|
|||||||
vars.TargetVersionMajor = targetVersionMajor.c_str();
|
vars.TargetVersionMajor = targetVersionMajor.c_str();
|
||||||
vars.TargetVersionMinor = targetVersionMinor.c_str();
|
vars.TargetVersionMinor = targetVersionMinor.c_str();
|
||||||
|
|
||||||
|
vars.RuleLauncher = "RULE_LAUNCH_LINK";
|
||||||
|
vars.CMTarget = this->Target;
|
||||||
vars.Language = linkLanguage;
|
vars.Language = linkLanguage;
|
||||||
vars.Objects = buildObjs.c_str();
|
vars.Objects = buildObjs.c_str();
|
||||||
std::string objdir = cmake::GetCMakeFilesDirectoryPostSlash();
|
std::string objdir = cmake::GetCMakeFilesDirectoryPostSlash();
|
||||||
|
@ -619,6 +619,8 @@ cmMakefileTargetGenerator
|
|||||||
cmLocalGenerator::SHELL);
|
cmLocalGenerator::SHELL);
|
||||||
}
|
}
|
||||||
cmLocalGenerator::RuleVariables vars;
|
cmLocalGenerator::RuleVariables vars;
|
||||||
|
vars.RuleLauncher = "RULE_LAUNCH_COMPILE";
|
||||||
|
vars.CMTarget = this->Target;
|
||||||
vars.Language = lang;
|
vars.Language = lang;
|
||||||
vars.TargetPDB = targetOutPathPDB.c_str();
|
vars.TargetPDB = targetOutPathPDB.c_str();
|
||||||
vars.Source = sourceFile.c_str();
|
vars.Source = sourceFile.c_str();
|
||||||
|
@ -522,6 +522,25 @@ void cmTarget::DefineProperties(cmake *cm)
|
|||||||
"On non-Apple platforms these files may be installed using the "
|
"On non-Apple platforms these files may be installed using the "
|
||||||
"RESOURCE option to the install(TARGETS) command.");
|
"RESOURCE option to the install(TARGETS) command.");
|
||||||
|
|
||||||
|
cm->DefineProperty
|
||||||
|
("RULE_LAUNCH_COMPILE", cmProperty::TARGET,
|
||||||
|
"Specify a launcher for compile rules.",
|
||||||
|
"See the global property of the same name for details. "
|
||||||
|
"This overrides the global and directory property for a target.",
|
||||||
|
true);
|
||||||
|
cm->DefineProperty
|
||||||
|
("RULE_LAUNCH_LINK", cmProperty::TARGET,
|
||||||
|
"Specify a launcher for link rules.",
|
||||||
|
"See the global property of the same name for details. "
|
||||||
|
"This overrides the global and directory property for a target.",
|
||||||
|
true);
|
||||||
|
cm->DefineProperty
|
||||||
|
("RULE_LAUNCH_CUSTOM", cmProperty::TARGET,
|
||||||
|
"Specify a launcher for custom rules.",
|
||||||
|
"See the global property of the same name for details. "
|
||||||
|
"This overrides the global and directory property for a target.",
|
||||||
|
true);
|
||||||
|
|
||||||
cm->DefineProperty
|
cm->DefineProperty
|
||||||
("SKIP_BUILD_RPATH", cmProperty::TARGET,
|
("SKIP_BUILD_RPATH", cmProperty::TARGET,
|
||||||
"Should rpaths be used for the build tree.",
|
"Should rpaths be used for the build tree.",
|
||||||
|
@ -3444,6 +3444,31 @@ void cmake::DefineProperties(cmake *cm)
|
|||||||
"enabled languages",
|
"enabled languages",
|
||||||
"Set to list of currently enabled lanauges.");
|
"Set to list of currently enabled lanauges.");
|
||||||
|
|
||||||
|
cm->DefineProperty
|
||||||
|
("RULE_LAUNCH_COMPILE", cmProperty::GLOBAL,
|
||||||
|
"Specify a launcher for compile rules.",
|
||||||
|
"Makefile generators prefix compiler commands with the given "
|
||||||
|
"launcher command line. "
|
||||||
|
"This is intended to allow launchers to intercept build problems "
|
||||||
|
"with high granularity. "
|
||||||
|
"Non-Makefile generators currently ignore this property.");
|
||||||
|
cm->DefineProperty
|
||||||
|
("RULE_LAUNCH_LINK", cmProperty::GLOBAL,
|
||||||
|
"Specify a launcher for link rules.",
|
||||||
|
"Makefile generators prefix link and archive commands with the given "
|
||||||
|
"launcher command line. "
|
||||||
|
"This is intended to allow launchers to intercept build problems "
|
||||||
|
"with high granularity. "
|
||||||
|
"Non-Makefile generators currently ignore this property.");
|
||||||
|
cm->DefineProperty
|
||||||
|
("RULE_LAUNCH_CUSTOM", cmProperty::GLOBAL,
|
||||||
|
"Specify a launcher for custom rules.",
|
||||||
|
"Makefile generators prefix custom commands with the given "
|
||||||
|
"launcher command line. "
|
||||||
|
"This is intended to allow launchers to intercept build problems "
|
||||||
|
"with high granularity. "
|
||||||
|
"Non-Makefile generators currently ignore this property.");
|
||||||
|
|
||||||
// ================================================================
|
// ================================================================
|
||||||
// define variables as well
|
// define variables as well
|
||||||
// ================================================================
|
// ================================================================
|
||||||
|
Loading…
x
Reference in New Issue
Block a user