cmGeneratorTarget: Add API for target-relative commands.

This commit is contained in:
Stephen Kelly 2015-10-23 00:42:58 +02:00
parent d288b216af
commit 3f8aa62bfb
13 changed files with 71 additions and 49 deletions

View File

@ -833,6 +833,24 @@ const char* cmGeneratorTarget::GetLocation(const std::string& config) const
return location.c_str();
}
std::vector<cmCustomCommand> const&
cmGeneratorTarget::GetPreBuildCommands() const
{
return this->Target->GetPreBuildCommands();
}
std::vector<cmCustomCommand> const&
cmGeneratorTarget::GetPreLinkCommands() const
{
return this->Target->GetPreLinkCommands();
}
std::vector<cmCustomCommand> const&
cmGeneratorTarget::GetPostBuildCommands() const
{
return this->Target->GetPostBuildCommands();
}
bool cmGeneratorTarget::IsImported() const
{
return this->Target->IsImported();
@ -2267,11 +2285,11 @@ cmTargetTraceDependencies
// Queue pre-build, pre-link, and post-build rule dependencies.
this->CheckCustomCommands(
this->GeneratorTarget->Target->GetPreBuildCommands());
this->GeneratorTarget->GetPreBuildCommands());
this->CheckCustomCommands(
this->GeneratorTarget->Target->GetPreLinkCommands());
this->GeneratorTarget->GetPreLinkCommands());
this->CheckCustomCommands(
this->GeneratorTarget->Target->GetPostBuildCommands());
this->GeneratorTarget->GetPostBuildCommands());
}
//----------------------------------------------------------------------------

View File

@ -33,6 +33,10 @@ public:
bool IsImported() const;
const char *GetLocation(const std::string& config) const;
std::vector<cmCustomCommand> const &GetPreBuildCommands() const;
std::vector<cmCustomCommand> const &GetPreLinkCommands() const;
std::vector<cmCustomCommand> const &GetPostBuildCommands() const;
#define DECLARE_TARGET_POLICY(POLICY) \
cmPolicies::PolicyStatus GetPolicyStatus ## POLICY () const \
{ return this->PolicyMap.Get(cmPolicies::POLICY); }

View File

@ -392,10 +392,10 @@ void cmGhsMultiTargetGenerator::WriteTargetLinkLibraries()
void cmGhsMultiTargetGenerator::WriteCustomCommands()
{
WriteCustomCommandsHelper(
this->GeneratorTarget->Target->GetPreBuildCommands(),
this->GeneratorTarget->GetPreBuildCommands(),
cmTarget::PRE_BUILD);
WriteCustomCommandsHelper(
this->GeneratorTarget->Target->GetPostBuildCommands(),
this->GeneratorTarget->GetPostBuildCommands(),
cmTarget::POST_BUILD);
}

View File

@ -1469,11 +1469,11 @@ void cmGlobalXCodeGenerator::CreateCustomCommands(cmXCodeObject* buildPhases,
cmGeneratorTarget* gtgt)
{
std::vector<cmCustomCommand> const & prebuild
= gtgt->Target->GetPreBuildCommands();
= gtgt->GetPreBuildCommands();
std::vector<cmCustomCommand> const & prelink
= gtgt->Target->GetPreLinkCommands();
= gtgt->GetPreLinkCommands();
std::vector<cmCustomCommand> postbuild
= gtgt->Target->GetPostBuildCommands();
= gtgt->GetPostBuildCommands();
if(gtgt->GetType() == cmState::SHARED_LIBRARY &&
!gtgt->IsFrameworkOnApple())

View File

@ -1787,15 +1787,15 @@ void cmLocalUnixMakefileGenerator3
// Global targets store their rules in pre- and post-build commands.
this->AppendCustomDepends(depends,
gt->Target->GetPreBuildCommands());
gt->GetPreBuildCommands());
this->AppendCustomDepends(depends,
gt->Target->GetPostBuildCommands());
gt->GetPostBuildCommands());
this->AppendCustomCommands(commands,
gt->Target->GetPreBuildCommands(),
gt->GetPreBuildCommands(),
gt,
cmLocalGenerator::START_OUTPUT);
this->AppendCustomCommands(commands,
gt->Target->GetPostBuildCommands(),
gt->GetPostBuildCommands(),
gt,
cmLocalGenerator::START_OUTPUT);
std::string targetName = gt->GetName();

View File

@ -266,21 +266,21 @@ void cmLocalVisualStudio6Generator::WriteDSPFile(std::ostream& fout,
// depend only on the previous rule.
if ((target->GetType() == cmState::UTILITY ||
target->GetType() == cmState::GLOBAL_TARGET) &&
(!target->Target->GetPreBuildCommands().empty() ||
!target->Target->GetPostBuildCommands().empty()))
(!target->GetPreBuildCommands().empty() ||
!target->GetPostBuildCommands().empty()))
{
// Accumulate the dependencies of all the commands.
std::vector<std::string> depends;
for (std::vector<cmCustomCommand>::const_iterator cr =
target->Target->GetPreBuildCommands().begin();
cr != target->Target->GetPreBuildCommands().end(); ++cr)
target->GetPreBuildCommands().begin();
cr != target->GetPreBuildCommands().end(); ++cr)
{
depends.insert(depends.end(),
cr->GetDepends().begin(), cr->GetDepends().end());
}
for (std::vector<cmCustomCommand>::const_iterator cr =
target->Target->GetPostBuildCommands().begin();
cr != target->Target->GetPostBuildCommands().end(); ++cr)
target->GetPostBuildCommands().begin();
cr != target->GetPostBuildCommands().end(); ++cr)
{
depends.insert(depends.end(),
cr->GetDepends().begin(), cr->GetDepends().end());
@ -289,14 +289,14 @@ void cmLocalVisualStudio6Generator::WriteDSPFile(std::ostream& fout,
// Add the pre- and post-build commands in order.
int count = 1;
for (std::vector<cmCustomCommand>::const_iterator cr =
target->Target->GetPreBuildCommands().begin();
cr != target->Target->GetPreBuildCommands().end(); ++cr)
target->GetPreBuildCommands().begin();
cr != target->GetPreBuildCommands().end(); ++cr)
{
this->AddUtilityCommandHack(target, count++, depends, *cr);
}
for (std::vector<cmCustomCommand>::const_iterator cr =
target->Target->GetPostBuildCommands().begin();
cr != target->Target->GetPostBuildCommands().end(); ++cr)
target->GetPostBuildCommands().begin();
cr != target->GetPostBuildCommands().end(); ++cr)
{
this->AddUtilityCommandHack(target, count++, depends, *cr);
}
@ -838,8 +838,8 @@ cmLocalVisualStudio6Generator::CreateTargetRules(cmGeneratorTarget *target,
// Write the pre-build and pre-link together (VS6 does not support both).
event.Start("PreLink");
event.Write(target->Target->GetPreBuildCommands());
event.Write(target->Target->GetPreLinkCommands());
event.Write(target->GetPreBuildCommands());
event.Write(target->GetPreLinkCommands());
cmsys::auto_ptr<cmCustomCommand> pcc(
this->MaybeCreateImplibDir(target, configName, false));
if(pcc.get())
@ -855,7 +855,7 @@ cmLocalVisualStudio6Generator::CreateTargetRules(cmGeneratorTarget *target,
// Write the post-build rules.
event.Start("PostBuild");
event.Write(target->Target->GetPostBuildCommands());
event.Write(target->GetPostBuildCommands());
event.Finish();
customRuleCode += "# End Special Build Tool\n";

View File

@ -2021,7 +2021,7 @@ void cmLocalVisualStudio7Generator
const char* tool =
this->FortranProject? "VFPreBuildEventTool":"VCPreBuildEventTool";
event.Start(tool);
event.Write(target->Target->GetPreBuildCommands());
event.Write(target->GetPreBuildCommands());
event.Finish();
// Add pre-link event.
@ -2035,7 +2035,7 @@ void cmLocalVisualStudio7Generator
{
addedPrelink = true;
std::vector<cmCustomCommand> commands =
target->Target->GetPreLinkCommands();
target->GetPreLinkCommands();
cmGlobalVisualStudioGenerator* gg
= static_cast<cmGlobalVisualStudioGenerator*>(this->GlobalGenerator);
gg->AddSymbolExportCommand(
@ -2045,7 +2045,7 @@ void cmLocalVisualStudio7Generator
}
if (!addedPrelink)
{
event.Write(target->Target->GetPreLinkCommands());
event.Write(target->GetPreLinkCommands());
}
cmsys::auto_ptr<cmCustomCommand> pcc(
this->MaybeCreateImplibDir(target,
@ -2059,7 +2059,7 @@ void cmLocalVisualStudio7Generator
// Add post-build event.
tool = this->FortranProject? "VFPostBuildEventTool":"VCPostBuildEventTool";
event.Start(tool);
event.Write(target->Target->GetPostBuildCommands());
event.Write(target->GetPostBuildCommands());
event.Finish();
}

View File

@ -279,11 +279,11 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
{
this->LocalGenerator
->AppendCustomCommands(commands,
this->GeneratorTarget->Target->GetPreBuildCommands(),
this->GeneratorTarget->GetPreBuildCommands(),
this->GeneratorTarget);
this->LocalGenerator
->AppendCustomCommands(commands,
this->GeneratorTarget->Target->GetPreLinkCommands(),
this->GeneratorTarget->GetPreLinkCommands(),
this->GeneratorTarget);
}
@ -450,7 +450,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
{
this->LocalGenerator->
AppendCustomCommands(commands,
this->GeneratorTarget->Target->GetPostBuildCommands(),
this->GeneratorTarget->GetPostBuildCommands(),
this->GeneratorTarget);
}

View File

@ -114,7 +114,7 @@ void cmMakefileLibraryTargetGenerator::WriteObjectLibraryRules()
// Add post-build rules.
this->LocalGenerator->
AppendCustomCommands(commands,
this->GeneratorTarget->Target->GetPostBuildCommands(),
this->GeneratorTarget->GetPostBuildCommands(),
this->GeneratorTarget);
// Depend on the object files.
@ -458,11 +458,11 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
{
this->LocalGenerator
->AppendCustomCommands(commands,
this->GeneratorTarget->Target->GetPreBuildCommands(),
this->GeneratorTarget->GetPreBuildCommands(),
this->GeneratorTarget);
this->LocalGenerator
->AppendCustomCommands(commands,
this->GeneratorTarget->Target->GetPreLinkCommands(),
this->GeneratorTarget->GetPreLinkCommands(),
this->GeneratorTarget);
}
@ -814,7 +814,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
{
this->LocalGenerator->
AppendCustomCommands(commands,
this->GeneratorTarget->Target->GetPostBuildCommands(),
this->GeneratorTarget->GetPostBuildCommands(),
this->GeneratorTarget);
}

View File

@ -67,20 +67,20 @@ void cmMakefileUtilityTargetGenerator::WriteRuleFiles()
// Utility targets store their rules in pre- and post-build commands.
this->LocalGenerator->AppendCustomDepends
(depends, this->GeneratorTarget->Target->GetPreBuildCommands());
(depends, this->GeneratorTarget->GetPreBuildCommands());
this->LocalGenerator->AppendCustomDepends
(depends, this->GeneratorTarget->Target->GetPostBuildCommands());
(depends, this->GeneratorTarget->GetPostBuildCommands());
this->LocalGenerator->AppendCustomCommands
(commands, this->GeneratorTarget->Target->GetPreBuildCommands(),
(commands, this->GeneratorTarget->GetPreBuildCommands(),
this->GeneratorTarget);
// Depend on all custom command outputs for sources
this->DriveCustomCommands(depends);
this->LocalGenerator->AppendCustomCommands
(commands, this->GeneratorTarget->Target->GetPostBuildCommands(),
(commands, this->GeneratorTarget->GetPostBuildCommands(),
this->GeneratorTarget);
// Add dependencies on targets that must be built first.

View File

@ -598,9 +598,9 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
}
const std::vector<cmCustomCommand> *cmdLists[3] = {
&gt.Target->GetPreBuildCommands(),
&gt.Target->GetPreLinkCommands(),
&gt.Target->GetPostBuildCommands()
&gt.GetPreBuildCommands(),
&gt.GetPreLinkCommands(),
&gt.GetPostBuildCommands()
};
std::vector<std::string> preLinkCmdLines, postBuildCmdLines;

View File

@ -33,8 +33,8 @@ void cmNinjaUtilityTargetGenerator::Generate()
cmNinjaDeps deps, outputs, util_outputs(1, utilCommandName);
const std::vector<cmCustomCommand> *cmdLists[2] = {
&this->GetGeneratorTarget()->Target->GetPreBuildCommands(),
&this->GetGeneratorTarget()->Target->GetPostBuildCommands()
&this->GetGeneratorTarget()->GetPreBuildCommands(),
&this->GetGeneratorTarget()->GetPostBuildCommands()
};
bool uses_terminal = false;

View File

@ -2814,7 +2814,7 @@ cmVisualStudio10TargetGenerator::WriteEvents(std::string const& configName)
{
addedPrelink = true;
std::vector<cmCustomCommand> commands =
this->GeneratorTarget->Target->GetPreLinkCommands();
this->GeneratorTarget->GetPreLinkCommands();
this->GlobalGenerator->AddSymbolExportCommand(
this->GeneratorTarget, commands, configName);
this->WriteEvent("PreLinkEvent", commands, configName);
@ -2823,12 +2823,12 @@ cmVisualStudio10TargetGenerator::WriteEvents(std::string const& configName)
if (!addedPrelink)
{
this->WriteEvent("PreLinkEvent",
this->GeneratorTarget->Target->GetPreLinkCommands(), configName);
this->GeneratorTarget->GetPreLinkCommands(), configName);
}
this->WriteEvent("PreBuildEvent",
this->GeneratorTarget->Target->GetPreBuildCommands(), configName);
this->GeneratorTarget->GetPreBuildCommands(), configName);
this->WriteEvent("PostBuildEvent",
this->GeneratorTarget->Target->GetPostBuildCommands(), configName);
this->GeneratorTarget->GetPostBuildCommands(), configName);
}
void cmVisualStudio10TargetGenerator::WriteEvent(