cmCustomCommandGenerator: Require cmLocalGenerator in API.
This commit is contained in:
parent
26d1a9d356
commit
d568eefe10
|
@ -12,14 +12,15 @@
|
|||
#include "cmCustomCommandGenerator.h"
|
||||
|
||||
#include "cmMakefile.h"
|
||||
#include "cmLocalGenerator.h"
|
||||
#include "cmCustomCommand.h"
|
||||
#include "cmOutputConverter.h"
|
||||
#include "cmGeneratorExpression.h"
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
cmCustomCommandGenerator::cmCustomCommandGenerator(
|
||||
cmCustomCommand const& cc, const std::string& config, cmMakefile* mf):
|
||||
CC(cc), Config(config), Makefile(mf),
|
||||
cmCustomCommand const& cc, const std::string& config, cmLocalGenerator* lg):
|
||||
CC(cc), Config(config), LG(lg),
|
||||
OldStyle(cc.GetEscapeOldStyle()), MakeVars(cc.GetEscapeAllowMakeVars()),
|
||||
GE(new cmGeneratorExpression(cc.GetBacktrace())), DependsDone(false)
|
||||
{
|
||||
|
@ -41,13 +42,15 @@ unsigned int cmCustomCommandGenerator::GetNumberOfCommands() const
|
|||
std::string cmCustomCommandGenerator::GetCommand(unsigned int c) const
|
||||
{
|
||||
std::string const& argv0 = this->CC.GetCommandLines()[c][0];
|
||||
cmTarget* target = this->Makefile->FindTargetToUse(argv0);
|
||||
cmTarget* target = this->LG->GetMakefile()->FindTargetToUse(argv0);
|
||||
if(target && target->GetType() == cmTarget::EXECUTABLE &&
|
||||
(target->IsImported() || !this->Makefile->IsOn("CMAKE_CROSSCOMPILING")))
|
||||
(target->IsImported()
|
||||
|| !this->LG->GetMakefile()->IsOn("CMAKE_CROSSCOMPILING")))
|
||||
{
|
||||
return target->GetLocation(this->Config);
|
||||
}
|
||||
return this->GE->Parse(argv0)->Evaluate(this->Makefile, this->Config);
|
||||
return this->GE->Parse(argv0)->Evaluate(this->LG->GetMakefile(),
|
||||
this->Config);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
@ -87,8 +90,9 @@ cmCustomCommandGenerator
|
|||
cmCustomCommandLine const& commandLine = this->CC.GetCommandLines()[c];
|
||||
for(unsigned int j=1;j < commandLine.size(); ++j)
|
||||
{
|
||||
std::string arg = this->GE->Parse(commandLine[j])->Evaluate(this->Makefile,
|
||||
this->Config);
|
||||
std::string arg =
|
||||
this->GE->Parse(commandLine[j])->Evaluate(this->LG->GetMakefile(),
|
||||
this->Config);
|
||||
cmd += " ";
|
||||
if(this->OldStyle)
|
||||
{
|
||||
|
@ -96,7 +100,7 @@ cmCustomCommandGenerator
|
|||
}
|
||||
else
|
||||
{
|
||||
cmOutputConverter converter(this->Makefile->GetStateSnapshot());
|
||||
cmOutputConverter converter(this->LG->GetMakefile()->GetStateSnapshot());
|
||||
cmd += converter.EscapeForShell(arg, this->MakeVars);
|
||||
}
|
||||
}
|
||||
|
@ -141,7 +145,7 @@ std::vector<std::string> const& cmCustomCommandGenerator::GetDepends() const
|
|||
= this->GE->Parse(*i);
|
||||
std::vector<std::string> result;
|
||||
cmSystemTools::ExpandListArgument(
|
||||
cge->Evaluate(this->Makefile, this->Config), result);
|
||||
cge->Evaluate(this->LG->GetMakefile(), this->Config), result);
|
||||
for (std::vector<std::string>::iterator it = result.begin();
|
||||
it != result.end(); ++it)
|
||||
{
|
||||
|
|
|
@ -15,14 +15,14 @@
|
|||
#include "cmStandardIncludes.h"
|
||||
|
||||
class cmCustomCommand;
|
||||
class cmMakefile;
|
||||
class cmLocalGenerator;
|
||||
class cmGeneratorExpression;
|
||||
|
||||
class cmCustomCommandGenerator
|
||||
{
|
||||
cmCustomCommand const& CC;
|
||||
std::string Config;
|
||||
cmMakefile* Makefile;
|
||||
cmLocalGenerator* LG;
|
||||
bool OldStyle;
|
||||
bool MakeVars;
|
||||
cmGeneratorExpression* GE;
|
||||
|
@ -31,7 +31,7 @@ class cmCustomCommandGenerator
|
|||
public:
|
||||
cmCustomCommandGenerator(cmCustomCommand const& cc,
|
||||
const std::string& config,
|
||||
cmMakefile* mf);
|
||||
cmLocalGenerator* lg);
|
||||
~cmCustomCommandGenerator();
|
||||
cmCustomCommand const& GetCC() const { return this->CC; }
|
||||
unsigned int GetNumberOfCommands() const;
|
||||
|
|
|
@ -938,7 +938,8 @@ void cmTargetTraceDependencies::FollowCommandDepends(cmCustomCommand const& cc,
|
|||
const std::string& config,
|
||||
std::set<std::string>& emitted)
|
||||
{
|
||||
cmCustomCommandGenerator ccg(cc, config, this->Makefile);
|
||||
cmCustomCommandGenerator ccg(cc, config,
|
||||
this->GeneratorTarget->LocalGenerator);
|
||||
|
||||
const std::vector<std::string>& depends = ccg.GetDepends();
|
||||
|
||||
|
|
|
@ -1668,7 +1668,7 @@ void cmGlobalXCodeGenerator
|
|||
for(std::vector<cmCustomCommand>::const_iterator i = commands.begin();
|
||||
i != commands.end(); ++i)
|
||||
{
|
||||
cmCustomCommandGenerator ccg(*i, configName, this->CurrentMakefile);
|
||||
cmCustomCommandGenerator ccg(*i, configName, this->CurrentLocalGenerator);
|
||||
if(ccg.GetNumberOfCommands() > 0)
|
||||
{
|
||||
const std::vector<std::string>& outputs = ccg.GetOutputs();
|
||||
|
@ -1694,7 +1694,7 @@ void cmGlobalXCodeGenerator
|
|||
for(std::vector<cmCustomCommand>::const_iterator i = commands.begin();
|
||||
i != commands.end(); ++i)
|
||||
{
|
||||
cmCustomCommandGenerator ccg(*i, configName, this->CurrentMakefile);
|
||||
cmCustomCommandGenerator ccg(*i, configName, this->CurrentLocalGenerator);
|
||||
if(ccg.GetNumberOfCommands() > 0)
|
||||
{
|
||||
makefileStream << "\n";
|
||||
|
|
|
@ -404,7 +404,7 @@ cmLocalNinjaGenerator::WriteCustomCommandBuildStatement(
|
|||
if (this->GetGlobalNinjaGenerator()->SeenCustomCommand(cc))
|
||||
return;
|
||||
|
||||
cmCustomCommandGenerator ccg(*cc, this->GetConfigName(), this->Makefile);
|
||||
cmCustomCommandGenerator ccg(*cc, this->GetConfigName(), this);
|
||||
|
||||
const std::vector<std::string> &outputs = ccg.GetOutputs();
|
||||
const std::vector<std::string> &byproducts = ccg.GetByproducts();
|
||||
|
|
|
@ -1007,8 +1007,7 @@ cmLocalUnixMakefileGenerator3
|
|||
for(std::vector<cmCustomCommand>::const_iterator i = ccs.begin();
|
||||
i != ccs.end(); ++i)
|
||||
{
|
||||
cmCustomCommandGenerator ccg(*i, this->ConfigName,
|
||||
this->Makefile);
|
||||
cmCustomCommandGenerator ccg(*i, this->ConfigName, this);
|
||||
this->AppendCustomDepend(depends, ccg);
|
||||
}
|
||||
}
|
||||
|
@ -1043,8 +1042,7 @@ cmLocalUnixMakefileGenerator3
|
|||
for(std::vector<cmCustomCommand>::const_iterator i = ccs.begin();
|
||||
i != ccs.end(); ++i)
|
||||
{
|
||||
cmCustomCommandGenerator ccg(*i, this->ConfigName,
|
||||
this->Makefile);
|
||||
cmCustomCommandGenerator ccg(*i, this->ConfigName, this);
|
||||
this->AppendCustomCommand(commands, ccg, target, true, relative);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -62,7 +62,7 @@ public:
|
|||
}
|
||||
void Write(cmCustomCommand const& cc)
|
||||
{
|
||||
cmCustomCommandGenerator ccg(cc, this->Config, this->LG->GetMakefile());
|
||||
cmCustomCommandGenerator ccg(cc, this->Config, this->LG);
|
||||
if(this->First)
|
||||
{
|
||||
this->Code += this->Event + "_Cmds=";
|
||||
|
@ -625,7 +625,7 @@ cmLocalVisualStudio6Generator
|
|||
for(i = this->Configurations.begin(); i != this->Configurations.end(); ++i)
|
||||
{
|
||||
std::string config = this->GetConfigName(*i);
|
||||
cmCustomCommandGenerator ccg(command, config, this->Makefile);
|
||||
cmCustomCommandGenerator ccg(command, config, this);
|
||||
std::string comment =
|
||||
this->ConstructComment(ccg, "Building Custom Rule $(InputPath)");
|
||||
if(comment == "<hack>")
|
||||
|
|
|
@ -619,7 +619,7 @@ public:
|
|||
}
|
||||
void Write(cmCustomCommand const& cc)
|
||||
{
|
||||
cmCustomCommandGenerator ccg(cc, this->Config, this->LG->GetMakefile());
|
||||
cmCustomCommandGenerator ccg(cc, this->Config, this->LG);
|
||||
if(this->First)
|
||||
{
|
||||
const char* comment = ccg.GetComment();
|
||||
|
@ -1903,7 +1903,7 @@ WriteCustomRule(std::ostream& fout,
|
|||
for (std::vector<std::string>::const_iterator i = configs.begin();
|
||||
i != configs.end(); ++i)
|
||||
{
|
||||
cmCustomCommandGenerator ccg(command, *i, this->Makefile);
|
||||
cmCustomCommandGenerator ccg(command, *i, this);
|
||||
cmLVS7GFileConfig const& fc = fcinfo.FileConfigMap[*i];
|
||||
fout << "\t\t\t\t<FileConfiguration\n";
|
||||
fout << "\t\t\t\t\tName=\"" << *i << "|"
|
||||
|
|
|
@ -167,7 +167,7 @@ void cmMakefileTargetGenerator::WriteTargetBuildRules()
|
|||
{
|
||||
cmCustomCommandGenerator ccg(*(*si)->GetCustomCommand(),
|
||||
this->ConfigName,
|
||||
this->Makefile);
|
||||
this->LocalGenerator);
|
||||
this->GenerateCustomRuleFile(ccg);
|
||||
if (clean)
|
||||
{
|
||||
|
@ -1182,7 +1182,8 @@ cmMakefileTargetGenerator
|
|||
{
|
||||
if(cmCustomCommand* cc = (*source)->GetCustomCommand())
|
||||
{
|
||||
cmCustomCommandGenerator ccg(*cc, this->ConfigName, this->Makefile);
|
||||
cmCustomCommandGenerator ccg(*cc, this->ConfigName,
|
||||
this->LocalGenerator);
|
||||
const std::vector<std::string>& outputs = ccg.GetOutputs();
|
||||
depends.insert(depends.end(), outputs.begin(), outputs.end());
|
||||
}
|
||||
|
|
|
@ -608,7 +608,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
|
|||
ci = cmdLists[i]->begin();
|
||||
ci != cmdLists[i]->end(); ++ci)
|
||||
{
|
||||
cmCustomCommandGenerator ccg(*ci, cfgName, mf);
|
||||
cmCustomCommandGenerator ccg(*ci, cfgName, this->GetLocalGenerator());
|
||||
localGen.AppendCustomCommandLines(ccg, *cmdLineLists[i]);
|
||||
std::vector<std::string> const& ccByproducts = ccg.GetByproducts();
|
||||
std::transform(ccByproducts.begin(), ccByproducts.end(),
|
||||
|
|
|
@ -509,7 +509,7 @@ cmNinjaTargetGenerator
|
|||
{
|
||||
cmCustomCommand const* cc = *cci;
|
||||
cmCustomCommandGenerator ccg(*cc, this->GetConfigName(),
|
||||
this->GetMakefile());
|
||||
this->GetLocalGenerator());
|
||||
const std::vector<std::string>& ccoutputs = ccg.GetOutputs();
|
||||
const std::vector<std::string>& ccbyproducts= ccg.GetByproducts();
|
||||
std::transform(ccoutputs.begin(), ccoutputs.end(),
|
||||
|
|
|
@ -44,7 +44,7 @@ void cmNinjaUtilityTargetGenerator::Generate()
|
|||
for (std::vector<cmCustomCommand>::const_iterator
|
||||
ci = cmdLists[i]->begin(); ci != cmdLists[i]->end(); ++ci) {
|
||||
cmCustomCommandGenerator ccg(*ci, this->GetConfigName(),
|
||||
this->GetMakefile());
|
||||
this->GetLocalGenerator());
|
||||
this->GetLocalGenerator()->AppendCustomCommandDeps(ccg, deps);
|
||||
this->GetLocalGenerator()->AppendCustomCommandLines(ccg, commands);
|
||||
std::vector<std::string> const& ccByproducts = ccg.GetByproducts();
|
||||
|
@ -65,7 +65,7 @@ void cmNinjaUtilityTargetGenerator::Generate()
|
|||
if(cmCustomCommand* cc = (*source)->GetCustomCommand())
|
||||
{
|
||||
cmCustomCommandGenerator ccg(*cc, this->GetConfigName(),
|
||||
this->GetMakefile());
|
||||
this->GetLocalGenerator());
|
||||
this->GetLocalGenerator()->AddCustomCommandTarget(cc, this->GetTarget());
|
||||
|
||||
// Depend on all custom command outputs.
|
||||
|
|
|
@ -890,7 +890,7 @@ cmVisualStudio10TargetGenerator::WriteCustomRule(cmSourceFile const* source,
|
|||
i = this->Configurations.begin();
|
||||
i != this->Configurations.end(); ++i)
|
||||
{
|
||||
cmCustomCommandGenerator ccg(command, *i, this->Makefile);
|
||||
cmCustomCommandGenerator ccg(command, *i, this->LocalGenerator);
|
||||
std::string comment = lg->ConstructComment(ccg);
|
||||
comment = cmVS10EscapeComment(comment);
|
||||
std::string script =
|
||||
|
@ -2794,7 +2794,7 @@ void cmVisualStudio10TargetGenerator::WriteEvent(
|
|||
for(std::vector<cmCustomCommand>::const_iterator i = commands.begin();
|
||||
i != commands.end(); ++i)
|
||||
{
|
||||
cmCustomCommandGenerator ccg(*i, configName, this->Makefile);
|
||||
cmCustomCommandGenerator ccg(*i, configName, this->LocalGenerator);
|
||||
comment += pre;
|
||||
comment += lg->ConstructComment(ccg);
|
||||
script += pre;
|
||||
|
|
Loading…
Reference in New Issue