cmTarget: Make custom command accessors API const.

Add specific mutators instead of providing non-const refs.
This commit is contained in:
Stephen Kelly 2013-11-19 11:05:47 +01:00
parent 0f876439e9
commit 50d152035d
7 changed files with 20 additions and 13 deletions

View File

@ -2407,7 +2407,7 @@ cmTarget cmGlobalGenerator::CreateGlobalTarget(
// Store the custom command in the target.
cmCustomCommand cc(0, no_outputs, no_depends, *commandLines, 0,
workingDirectory);
target.GetPostBuildCommands().push_back(cc);
target.AddPostBuildCommand(cc);
target.SetProperty("EchoString", message);
std::vector<std::string>::iterator dit;
for ( dit = depends.begin(); dit != depends.end(); ++ dit )

View File

@ -903,13 +903,13 @@ cmMakefile::AddCustomCommandToTarget(const char* target,
switch(type)
{
case cmTarget::PRE_BUILD:
ti->second.GetPreBuildCommands().push_back(cc);
ti->second.AddPreBuildCommand(cc);
break;
case cmTarget::PRE_LINK:
ti->second.GetPreLinkCommands().push_back(cc);
ti->second.AddPreLinkCommand(cc);
break;
case cmTarget::POST_BUILD:
ti->second.GetPostBuildCommands().push_back(cc);
ti->second.AddPostBuildCommand(cc);
break;
}
}

View File

@ -534,7 +534,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
std::replace(linkLibraries.begin(), linkLibraries.end(), '\\', '/');
}
std::vector<cmCustomCommand> *cmdLists[3] = {
const std::vector<cmCustomCommand> *cmdLists[3] = {
&this->GetTarget()->GetPreBuildCommands(),
&this->GetTarget()->GetPreLinkCommands(),
&this->GetTarget()->GetPostBuildCommands()

View File

@ -257,7 +257,7 @@ bool cmQtAutoGenerators::InitializeAutogenTarget(cmTarget* target)
workingDirectory.c_str());
cc.SetEscapeOldStyle(false);
cc.SetEscapeAllowMakeVars(true);
target->GetPreBuildCommands().push_back(cc);
target->AddPreBuildCommand(cc);
}
else
#endif

View File

@ -114,12 +114,18 @@ public:
/**
* Get the list of the custom commands for this target
*/
std::vector<cmCustomCommand> &GetPreBuildCommands()
std::vector<cmCustomCommand> const &GetPreBuildCommands() const
{return this->PreBuildCommands;}
std::vector<cmCustomCommand> &GetPreLinkCommands()
std::vector<cmCustomCommand> const &GetPreLinkCommands() const
{return this->PreLinkCommands;}
std::vector<cmCustomCommand> &GetPostBuildCommands()
std::vector<cmCustomCommand> const &GetPostBuildCommands() const
{return this->PostBuildCommands;}
void AddPreBuildCommand(cmCustomCommand const &cmd)
{this->PreBuildCommands.push_back(cmd);}
void AddPreLinkCommand(cmCustomCommand const &cmd)
{this->PreLinkCommands.push_back(cmd);}
void AddPostBuildCommand(cmCustomCommand const &cmd)
{this->PostBuildCommands.push_back(cmd);}
/**
* Get the list of the source files used by this target

View File

@ -1794,7 +1794,7 @@ cmVisualStudio10TargetGenerator::WriteEvents(std::string const& configName)
void cmVisualStudio10TargetGenerator::WriteEvent(
const char* name,
std::vector<cmCustomCommand> & commands,
std::vector<cmCustomCommand> const& commands,
std::string const& configName)
{
if(commands.size() == 0)
@ -1807,10 +1807,10 @@ void cmVisualStudio10TargetGenerator::WriteEvent(
std::string script;
const char* pre = "";
std::string comment;
for(std::vector<cmCustomCommand>::iterator i = commands.begin();
for(std::vector<cmCustomCommand>::const_iterator i = commands.begin();
i != commands.end(); ++i)
{
cmCustomCommand& command = *i;
const cmCustomCommand& command = *i;
comment += pre;
comment += lg->ConstructComment(command);
script += pre;

View File

@ -87,7 +87,8 @@ private:
void AddLibraries(cmComputeLinkInformation& cli, std::string& libstring);
void WriteLibOptions(std::string const& config);
void WriteEvents(std::string const& configName);
void WriteEvent(const char* name, std::vector<cmCustomCommand> & commands,
void WriteEvent(const char* name,
std::vector<cmCustomCommand> const& commands,
std::string const& configName);
void WriteGroupSources(const char* name, ToolSources const& sources,
std::vector<cmSourceGroup>& );