Generalize cmCustomCommandGenerator to more fields

Until now the cmCustomCommandGenerator was used only to compute the
command lines of a custom command.  Generalize it to get the comment,
working directory, dependencies, and outputs of custom commands.  Update
use in all generators to support this.
This commit is contained in:
Brad King 2014-03-10 15:47:19 -04:00
parent 9a5c554414
commit bc993f277e
19 changed files with 182 additions and 123 deletions

View File

@ -71,3 +71,27 @@ cmCustomCommandGenerator
} }
} }
} }
//----------------------------------------------------------------------------
const char* cmCustomCommandGenerator::GetComment() const
{
return this->CC.GetComment();
}
//----------------------------------------------------------------------------
std::string cmCustomCommandGenerator::GetWorkingDirectory() const
{
return this->CC.GetWorkingDirectory();
}
//----------------------------------------------------------------------------
std::vector<std::string> const& cmCustomCommandGenerator::GetOutputs() const
{
return this->CC.GetOutputs();
}
//----------------------------------------------------------------------------
std::vector<std::string> const& cmCustomCommandGenerator::GetDepends() const
{
return this->CC.GetDepends();
}

View File

@ -33,9 +33,14 @@ public:
const std::string& config, const std::string& config,
cmMakefile* mf); cmMakefile* mf);
~cmCustomCommandGenerator(); ~cmCustomCommandGenerator();
cmCustomCommand const& GetCC() const { return this->CC; }
unsigned int GetNumberOfCommands() const; unsigned int GetNumberOfCommands() const;
std::string GetCommand(unsigned int c) const; std::string GetCommand(unsigned int c) const;
void AppendArguments(unsigned int c, std::string& cmd) const; void AppendArguments(unsigned int c, std::string& cmd) const;
const char* GetComment() const;
std::string GetWorkingDirectory() const;
std::vector<std::string> const& GetOutputs() const;
std::vector<std::string> const& GetDepends() const;
}; };
#endif #endif

View File

@ -1546,10 +1546,10 @@ void cmGlobalXCodeGenerator
for(std::vector<cmCustomCommand>::const_iterator i = commands.begin(); for(std::vector<cmCustomCommand>::const_iterator i = commands.begin();
i != commands.end(); ++i) i != commands.end(); ++i)
{ {
cmCustomCommand const& cc = *i; cmCustomCommandGenerator ccg(*i, configName, this->CurrentMakefile);
if(!cc.GetCommandLines().empty()) if(ccg.GetNumberOfCommands() > 0)
{ {
const std::vector<std::string>& outputs = cc.GetOutputs(); const std::vector<std::string>& outputs = ccg.GetOutputs();
if(!outputs.empty()) if(!outputs.empty())
{ {
for(std::vector<std::string>::const_iterator o = outputs.begin(); for(std::vector<std::string>::const_iterator o = outputs.begin();
@ -1573,8 +1573,8 @@ void cmGlobalXCodeGenerator
{ {
cmOStringStream str; cmOStringStream str;
str << "_buildpart_" << count++ ; str << "_buildpart_" << count++ ;
tname[&cc] = std::string(target.GetName()) + str.str(); tname[&ccg.GetCC()] = std::string(target.GetName()) + str.str();
makefileStream << "\\\n\t" << tname[&cc]; makefileStream << "\\\n\t" << tname[&ccg.GetCC()];
} }
} }
} }
@ -1582,12 +1582,11 @@ void cmGlobalXCodeGenerator
for(std::vector<cmCustomCommand>::const_iterator i = commands.begin(); for(std::vector<cmCustomCommand>::const_iterator i = commands.begin();
i != commands.end(); ++i) i != commands.end(); ++i)
{ {
cmCustomCommand const& cc = *i; cmCustomCommandGenerator ccg(*i, configName, this->CurrentMakefile);
if(!cc.GetCommandLines().empty()) if(ccg.GetNumberOfCommands() > 0)
{ {
cmCustomCommandGenerator ccg(cc, configName, this->CurrentMakefile);
makefileStream << "\n"; makefileStream << "\n";
const std::vector<std::string>& outputs = cc.GetOutputs(); const std::vector<std::string>& outputs = ccg.GetOutputs();
if(!outputs.empty()) if(!outputs.empty())
{ {
// There is at least one output, start the rule for it // There is at least one output, start the rule for it
@ -1598,11 +1597,11 @@ void cmGlobalXCodeGenerator
else else
{ {
// There are no outputs. Use the generated force rule name. // There are no outputs. Use the generated force rule name.
makefileStream << tname[&cc] << ": "; makefileStream << tname[&ccg.GetCC()] << ": ";
} }
for(std::vector<std::string>::const_iterator d = for(std::vector<std::string>::const_iterator d =
cc.GetDepends().begin(); ccg.GetDepends().begin();
d != cc.GetDepends().end(); ++d) d != ccg.GetDepends().end(); ++d)
{ {
std::string dep; std::string dep;
if(this->CurrentLocalGenerator if(this->CurrentLocalGenerator
@ -1614,11 +1613,11 @@ void cmGlobalXCodeGenerator
} }
makefileStream << "\n"; makefileStream << "\n";
if(const char* comment = cc.GetComment()) if(const char* comment = ccg.GetComment())
{ {
std::string echo_cmd = "echo "; std::string echo_cmd = "echo ";
echo_cmd += (this->CurrentLocalGenerator-> echo_cmd += (this->CurrentLocalGenerator->
EscapeForShell(comment, cc.GetEscapeAllowMakeVars())); EscapeForShell(comment, ccg.GetCC().GetEscapeAllowMakeVars()));
makefileStream << "\t" << echo_cmd.c_str() << "\n"; makefileStream << "\t" << echo_cmd.c_str() << "\n";
} }
@ -1630,7 +1629,7 @@ void cmGlobalXCodeGenerator
cmSystemTools::ReplaceString(cmd2, "/./", "/"); cmSystemTools::ReplaceString(cmd2, "/./", "/");
cmd2 = this->ConvertToRelativeForMake(cmd2.c_str()); cmd2 = this->ConvertToRelativeForMake(cmd2.c_str());
std::string cmd; std::string cmd;
std::string wd = cc.GetWorkingDirectory(); std::string wd = ccg.GetWorkingDirectory();
if(!wd.empty()) if(!wd.empty())
{ {
cmd += "cd "; cmd += "cd ";

View File

@ -22,6 +22,7 @@
#include "cmSourceFile.h" #include "cmSourceFile.h"
#include "cmTest.h" #include "cmTest.h"
#include "cmTestGenerator.h" #include "cmTestGenerator.h"
#include "cmCustomCommandGenerator.h"
#include "cmVersion.h" #include "cmVersion.h"
#include "cmake.h" #include "cmake.h"
@ -2482,23 +2483,23 @@ void cmLocalGenerator::AppendFeatureOptions(
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
std::string std::string
cmLocalGenerator::ConstructComment(const cmCustomCommand& cc, cmLocalGenerator::ConstructComment(cmCustomCommandGenerator const& ccg,
const char* default_comment) const char* default_comment)
{ {
// Check for a comment provided with the command. // Check for a comment provided with the command.
if(cc.GetComment()) if(ccg.GetComment())
{ {
return cc.GetComment(); return ccg.GetComment();
} }
// Construct a reasonable default comment if possible. // Construct a reasonable default comment if possible.
if(!cc.GetOutputs().empty()) if(!ccg.GetOutputs().empty())
{ {
std::string comment; std::string comment;
comment = "Generating "; comment = "Generating ";
const char* sep = ""; const char* sep = "";
for(std::vector<std::string>::const_iterator o = cc.GetOutputs().begin(); for(std::vector<std::string>::const_iterator o = ccg.GetOutputs().begin();
o != cc.GetOutputs().end(); ++o) o != ccg.GetOutputs().end(); ++o)
{ {
comment += sep; comment += sep;
comment += this->Convert(*o, cmLocalGenerator::START_OUTPUT); comment += this->Convert(*o, cmLocalGenerator::START_OUTPUT);

View File

@ -21,6 +21,7 @@ class cmTarget;
class cmTargetManifest; class cmTargetManifest;
class cmSourceFile; class cmSourceFile;
class cmCustomCommand; class cmCustomCommand;
class cmCustomCommandGenerator;
/** \class cmLocalGenerator /** \class cmLocalGenerator
* \brief Create required build files for a directory. * \brief Create required build files for a directory.
@ -350,7 +351,7 @@ public:
const std::string& targetName, const std::string& targetName,
const char* fname); const char* fname);
/** Construct a comment for a custom command. */ /** Construct a comment for a custom command. */
std::string ConstructComment(const cmCustomCommand& cc, std::string ConstructComment(cmCustomCommandGenerator const& ccg,
const char* default_comment = ""); const char* default_comment = "");
// Compute object file names. // Compute object file names.
std::string GetObjectFileNameWithoutTarget(const cmSourceFile& source, std::string GetObjectFileNameWithoutTarget(const cmSourceFile& source,

View File

@ -303,10 +303,11 @@ cmLocalNinjaGenerator
this->GetGlobalNinjaGenerator()->AppendTargetDepends(target, outputs); this->GetGlobalNinjaGenerator()->AppendTargetDepends(target, outputs);
} }
void cmLocalNinjaGenerator::AppendCustomCommandDeps(const cmCustomCommand *cc, void cmLocalNinjaGenerator::AppendCustomCommandDeps(
cmNinjaDeps &ninjaDeps) cmCustomCommandGenerator const& ccg,
cmNinjaDeps &ninjaDeps)
{ {
const std::vector<std::string> &deps = cc->GetDepends(); const std::vector<std::string> &deps = ccg.GetDepends();
for (std::vector<std::string>::const_iterator i = deps.begin(); for (std::vector<std::string>::const_iterator i = deps.begin();
i != deps.end(); ++i) { i != deps.end(); ++i) {
std::string dep; std::string dep;
@ -359,12 +360,12 @@ std::string cmLocalNinjaGenerator::BuildCommandLine(
return cmd.str(); return cmd.str();
} }
void cmLocalNinjaGenerator::AppendCustomCommandLines(const cmCustomCommand *cc, void cmLocalNinjaGenerator::AppendCustomCommandLines(
std::vector<std::string> &cmdLines) cmCustomCommandGenerator const& ccg,
std::vector<std::string> &cmdLines)
{ {
cmCustomCommandGenerator ccg(*cc, this->GetConfigName(), this->Makefile);
if (ccg.GetNumberOfCommands() > 0) { if (ccg.GetNumberOfCommands() > 0) {
std::string wd = cc->GetWorkingDirectory(); std::string wd = ccg.GetWorkingDirectory();
if (wd.empty()) if (wd.empty())
wd = this->GetMakefile()->GetStartOutputDirectory(); wd = this->GetMakefile()->GetStartOutputDirectory();
@ -378,7 +379,7 @@ void cmLocalNinjaGenerator::AppendCustomCommandLines(const cmCustomCommand *cc,
cmdLines.push_back(cdCmd.str()); cmdLines.push_back(cdCmd.str());
} }
std::string launcher = this->MakeCustomLauncher(*cc); std::string launcher = this->MakeCustomLauncher(ccg);
for (unsigned i = 0; i != ccg.GetNumberOfCommands(); ++i) { for (unsigned i = 0; i != ccg.GetNumberOfCommands(); ++i) {
cmdLines.push_back(launcher + cmdLines.push_back(launcher +
@ -396,19 +397,21 @@ cmLocalNinjaGenerator::WriteCustomCommandBuildStatement(
if (this->GetGlobalNinjaGenerator()->SeenCustomCommand(cc)) if (this->GetGlobalNinjaGenerator()->SeenCustomCommand(cc))
return; return;
const std::vector<std::string> &outputs = cc->GetOutputs(); cmCustomCommandGenerator ccg(*cc, this->GetConfigName(), this->Makefile);
const std::vector<std::string> &outputs = ccg.GetOutputs();
cmNinjaDeps ninjaOutputs(outputs.size()), ninjaDeps; cmNinjaDeps ninjaOutputs(outputs.size()), ninjaDeps;
std::transform(outputs.begin(), outputs.end(), std::transform(outputs.begin(), outputs.end(),
ninjaOutputs.begin(), MapToNinjaPath()); ninjaOutputs.begin(), MapToNinjaPath());
this->AppendCustomCommandDeps(cc, ninjaDeps); this->AppendCustomCommandDeps(ccg, ninjaDeps);
for (cmNinjaDeps::iterator i = ninjaOutputs.begin(); i != ninjaOutputs.end(); for (cmNinjaDeps::iterator i = ninjaOutputs.begin(); i != ninjaOutputs.end();
++i) ++i)
this->GetGlobalNinjaGenerator()->SeenCustomCommandOutput(*i); this->GetGlobalNinjaGenerator()->SeenCustomCommandOutput(*i);
std::vector<std::string> cmdLines; std::vector<std::string> cmdLines;
this->AppendCustomCommandLines(cc, cmdLines); this->AppendCustomCommandLines(ccg, cmdLines);
if (cmdLines.empty()) { if (cmdLines.empty()) {
this->GetGlobalNinjaGenerator()->WritePhonyBuild( this->GetGlobalNinjaGenerator()->WritePhonyBuild(
@ -423,7 +426,7 @@ cmLocalNinjaGenerator::WriteCustomCommandBuildStatement(
} else { } else {
this->GetGlobalNinjaGenerator()->WriteCustomCommandBuild( this->GetGlobalNinjaGenerator()->WriteCustomCommandBuild(
this->BuildCommandLine(cmdLines), this->BuildCommandLine(cmdLines),
this->ConstructComment(*cc), this->ConstructComment(ccg),
"Custom command for " + ninjaOutputs[0], "Custom command for " + ninjaOutputs[0],
ninjaOutputs, ninjaOutputs,
ninjaDeps, ninjaDeps,
@ -472,7 +475,7 @@ void cmLocalNinjaGenerator::WriteCustomCommandBuildStatements()
} }
std::string cmLocalNinjaGenerator::MakeCustomLauncher( std::string cmLocalNinjaGenerator::MakeCustomLauncher(
const cmCustomCommand& cc) cmCustomCommandGenerator const& ccg)
{ {
const char* property = "RULE_LAUNCH_CUSTOM"; const char* property = "RULE_LAUNCH_CUSTOM";
const char* property_value = this->Makefile->GetProperty(property); const char* property_value = this->Makefile->GetProperty(property);
@ -487,11 +490,11 @@ std::string cmLocalNinjaGenerator::MakeCustomLauncher(
RuleVariables vars; RuleVariables vars;
vars.RuleLauncher = property; vars.RuleLauncher = property;
std::string output; std::string output;
const std::vector<std::string>& outputs = cc.GetOutputs(); const std::vector<std::string>& outputs = ccg.GetOutputs();
if(!outputs.empty()) if(!outputs.empty())
{ {
RelativeRoot relative_root = RelativeRoot relative_root =
cc.GetWorkingDirectory().empty() ? START_OUTPUT : NONE; ccg.GetWorkingDirectory().empty() ? START_OUTPUT : NONE;
output = this->Convert(outputs[0], relative_root, SHELL); output = this->Convert(outputs[0], relative_root, SHELL);
} }

View File

@ -16,6 +16,7 @@
# include "cmLocalGenerator.h" # include "cmLocalGenerator.h"
# include "cmNinjaTypes.h" # include "cmNinjaTypes.h"
class cmCustomCommandGenerator;
class cmGlobalNinjaGenerator; class cmGlobalNinjaGenerator;
class cmGeneratedFileStream; class cmGeneratedFileStream;
class cmake; class cmake;
@ -92,9 +93,9 @@ public:
void AppendTargetDepends(cmTarget* target, cmNinjaDeps& outputs); void AppendTargetDepends(cmTarget* target, cmNinjaDeps& outputs);
void AddCustomCommandTarget(cmCustomCommand const* cc, cmTarget* target); void AddCustomCommandTarget(cmCustomCommand const* cc, cmTarget* target);
void AppendCustomCommandLines(const cmCustomCommand *cc, void AppendCustomCommandLines(cmCustomCommandGenerator const& ccg,
std::vector<std::string> &cmdLines); std::vector<std::string> &cmdLines);
void AppendCustomCommandDeps(const cmCustomCommand *cc, void AppendCustomCommandDeps(cmCustomCommandGenerator const& ccg,
cmNinjaDeps &ninjaDeps); cmNinjaDeps &ninjaDeps);
virtual std::string ConvertToLinkReference(std::string const& lib, virtual std::string ConvertToLinkReference(std::string const& lib,
@ -124,7 +125,7 @@ private:
void WriteCustomCommandBuildStatements(); void WriteCustomCommandBuildStatements();
std::string MakeCustomLauncher(const cmCustomCommand& cc); std::string MakeCustomLauncher(cmCustomCommandGenerator const& ccg);
std::string ConfigName; std::string ConfigName;
std::string HomeRelativeOutputPath; std::string HomeRelativeOutputPath;

View File

@ -960,7 +960,9 @@ cmLocalUnixMakefileGenerator3
for(std::vector<cmCustomCommand>::const_iterator i = ccs.begin(); for(std::vector<cmCustomCommand>::const_iterator i = ccs.begin();
i != ccs.end(); ++i) i != ccs.end(); ++i)
{ {
this->AppendCustomDepend(depends, *i); cmCustomCommandGenerator ccg(*i, this->ConfigurationName,
this->Makefile);
this->AppendCustomDepend(depends, ccg);
} }
} }
@ -968,10 +970,10 @@ cmLocalUnixMakefileGenerator3
void void
cmLocalUnixMakefileGenerator3 cmLocalUnixMakefileGenerator3
::AppendCustomDepend(std::vector<std::string>& depends, ::AppendCustomDepend(std::vector<std::string>& depends,
const cmCustomCommand& cc) cmCustomCommandGenerator const& ccg)
{ {
for(std::vector<std::string>::const_iterator d = cc.GetDepends().begin(); for(std::vector<std::string>::const_iterator d = ccg.GetDepends().begin();
d != cc.GetDepends().end(); ++d) d != ccg.GetDepends().end(); ++d)
{ {
// Lookup the real name of the dependency in case it is a CMake target. // Lookup the real name of the dependency in case it is a CMake target.
std::string dep; std::string dep;
@ -994,7 +996,9 @@ cmLocalUnixMakefileGenerator3
for(std::vector<cmCustomCommand>::const_iterator i = ccs.begin(); for(std::vector<cmCustomCommand>::const_iterator i = ccs.begin();
i != ccs.end(); ++i) i != ccs.end(); ++i)
{ {
this->AppendCustomCommand(commands, *i, target, true, relative); cmCustomCommandGenerator ccg(*i, this->ConfigurationName,
this->Makefile);
this->AppendCustomCommand(commands, ccg, target, true, relative);
} }
} }
@ -1002,7 +1006,7 @@ cmLocalUnixMakefileGenerator3
void void
cmLocalUnixMakefileGenerator3 cmLocalUnixMakefileGenerator3
::AppendCustomCommand(std::vector<std::string>& commands, ::AppendCustomCommand(std::vector<std::string>& commands,
const cmCustomCommand& cc, cmCustomCommandGenerator const& ccg,
cmTarget* target, cmTarget* target,
bool echo_comment, bool echo_comment,
cmLocalGenerator::RelativeRoot relative, cmLocalGenerator::RelativeRoot relative,
@ -1014,8 +1018,8 @@ cmLocalUnixMakefileGenerator3
// their comments generated elsewhere. // their comments generated elsewhere.
if(echo_comment) if(echo_comment)
{ {
const char* comment = cc.GetComment(); const char* comment = ccg.GetComment();
if(comment && *comment) if(comment && !*comment)
{ {
this->AppendEcho(commands, comment, this->AppendEcho(commands, comment,
cmLocalUnixMakefileGenerator3::EchoGenerate); cmLocalUnixMakefileGenerator3::EchoGenerate);
@ -1024,7 +1028,7 @@ cmLocalUnixMakefileGenerator3
// if the command specified a working directory use it. // if the command specified a working directory use it.
std::string dir = this->Makefile->GetStartOutputDirectory(); std::string dir = this->Makefile->GetStartOutputDirectory();
std::string workingDir = cc.GetWorkingDirectory(); std::string workingDir = ccg.GetWorkingDirectory();
if(!workingDir.empty()) if(!workingDir.empty())
{ {
dir = workingDir; dir = workingDir;
@ -1033,8 +1037,6 @@ cmLocalUnixMakefileGenerator3
{ {
*content << dir; *content << dir;
} }
cmCustomCommandGenerator ccg(cc, this->ConfigurationName,
this->Makefile);
// Add each command line to the set of commands. // Add each command line to the set of commands.
std::vector<std::string> commands1; std::vector<std::string> commands1;
@ -1079,7 +1081,7 @@ cmLocalUnixMakefileGenerator3
cmd = "./" + cmd; cmd = "./" + cmd;
} }
std::string launcher = std::string launcher =
this->MakeLauncher(cc, target, this->MakeLauncher(ccg, target,
workingDir.empty()? START_OUTPUT : NONE); workingDir.empty()? START_OUTPUT : NONE);
cmd = launcher + this->ConvertShellCommand(cmd, NONE); cmd = launcher + this->ConvertShellCommand(cmd, NONE);
@ -1134,9 +1136,9 @@ cmLocalUnixMakefileGenerator3
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
std::string std::string
cmLocalUnixMakefileGenerator3::MakeLauncher(const cmCustomCommand& cc, cmLocalUnixMakefileGenerator3::MakeLauncher(
cmTarget* target, cmCustomCommandGenerator const& ccg,
RelativeRoot relative) cmTarget* target, RelativeRoot relative)
{ {
// Short-circuit if there is no launcher. // Short-circuit if there is no launcher.
const char* prop = "RULE_LAUNCH_CUSTOM"; const char* prop = "RULE_LAUNCH_CUSTOM";
@ -1152,7 +1154,7 @@ cmLocalUnixMakefileGenerator3::MakeLauncher(const cmCustomCommand& cc,
vars.RuleLauncher = prop; vars.RuleLauncher = prop;
vars.CMTarget = target; vars.CMTarget = target;
std::string output; std::string output;
const std::vector<std::string>& outputs = cc.GetOutputs(); const std::vector<std::string>& outputs = ccg.GetOutputs();
if(!outputs.empty()) if(!outputs.empty())
{ {
output = this->Convert(outputs[0], relative, SHELL); output = this->Convert(outputs[0], relative, SHELL);

View File

@ -18,6 +18,7 @@
#include "cmDepends.h" #include "cmDepends.h"
class cmCustomCommand; class cmCustomCommand;
class cmCustomCommandGenerator;
class cmDependInformation; class cmDependInformation;
class cmDepends; class cmDepends;
class cmMakefileTargetGenerator; class cmMakefileTargetGenerator;
@ -289,14 +290,14 @@ protected:
void AppendCustomDepends(std::vector<std::string>& depends, void AppendCustomDepends(std::vector<std::string>& depends,
const std::vector<cmCustomCommand>& ccs); const std::vector<cmCustomCommand>& ccs);
void AppendCustomDepend(std::vector<std::string>& depends, void AppendCustomDepend(std::vector<std::string>& depends,
const cmCustomCommand& cc); cmCustomCommandGenerator const& cc);
void AppendCustomCommands(std::vector<std::string>& commands, void AppendCustomCommands(std::vector<std::string>& commands,
const std::vector<cmCustomCommand>& ccs, const std::vector<cmCustomCommand>& ccs,
cmTarget* target, cmTarget* target,
cmLocalGenerator::RelativeRoot relative = cmLocalGenerator::RelativeRoot relative =
cmLocalGenerator::HOME_OUTPUT); cmLocalGenerator::HOME_OUTPUT);
void AppendCustomCommand(std::vector<std::string>& commands, void AppendCustomCommand(std::vector<std::string>& commands,
const cmCustomCommand& cc, cmCustomCommandGenerator const& ccg,
cmTarget* target, cmTarget* target,
bool echo_comment=false, bool echo_comment=false,
cmLocalGenerator::RelativeRoot relative = cmLocalGenerator::RelativeRoot relative =
@ -313,8 +314,8 @@ protected:
private: private:
std::string ConvertShellCommand(std::string const& cmd, RelativeRoot root); std::string ConvertShellCommand(std::string const& cmd, RelativeRoot root);
std::string MakeLauncher(const cmCustomCommand& cc, cmTarget* target, std::string MakeLauncher(cmCustomCommandGenerator const& ccg,
RelativeRoot relative); cmTarget* target, RelativeRoot relative);
friend class cmMakefileTargetGenerator; friend class cmMakefileTargetGenerator;
friend class cmMakefileExecutableTargetGenerator; friend class cmMakefileExecutableTargetGenerator;

View File

@ -16,6 +16,7 @@
#include "cmSourceFile.h" #include "cmSourceFile.h"
#include "cmCacheManager.h" #include "cmCacheManager.h"
#include "cmGeneratorTarget.h" #include "cmGeneratorTarget.h"
#include "cmCustomCommandGenerator.h"
#include "cmake.h" #include "cmake.h"
#include "cmComputeLinkInformation.h" #include "cmComputeLinkInformation.h"
@ -59,6 +60,7 @@ public:
} }
void Write(cmCustomCommand const& cc) void Write(cmCustomCommand const& cc)
{ {
cmCustomCommandGenerator ccg(cc, this->Config, this->LG->GetMakefile());
if(this->First) if(this->First)
{ {
this->Code += this->Event + "_Cmds="; this->Code += this->Event + "_Cmds=";
@ -68,7 +70,7 @@ public:
{ {
this->Code += "\\\n\t"; this->Code += "\\\n\t";
} }
this->Code += this->LG->ConstructScript(cc, this->Config, "\\\n\t"); this->Code += this->LG->ConstructScript(ccg, "\\\n\t");
} }
private: private:
cmLocalVisualStudio6Generator* LG; cmLocalVisualStudio6Generator* LG;
@ -575,14 +577,18 @@ cmLocalVisualStudio6Generator
target.GetName().size() + 30)]; target.GetName().size() + 30)];
sprintf(output,"%s/%s_force_%i", this->Makefile->GetStartOutputDirectory(), sprintf(output,"%s/%s_force_%i", this->Makefile->GetStartOutputDirectory(),
target.GetName().c_str(), count); target.GetName().c_str(), count);
std::string comment = this->ConstructComment(origCommand, "<hack>"); const char* comment = origCommand.GetComment();
if(!comment && origCommand.GetOutputs().empty())
{
comment = "<hack>";
}
// Add the rule with the given dependencies and commands. // Add the rule with the given dependencies and commands.
std::string no_main_dependency = ""; std::string no_main_dependency = "";
if(cmSourceFile* outsf = if(cmSourceFile* outsf =
this->Makefile->AddCustomCommandToOutput( this->Makefile->AddCustomCommandToOutput(
output, depends, no_main_dependency, output, depends, no_main_dependency,
origCommand.GetCommandLines(), comment.c_str(), origCommand.GetCommandLines(), comment,
origCommand.GetWorkingDirectory().c_str())) origCommand.GetWorkingDirectory().c_str()))
{ {
target.AddSourceFile(outsf); target.AddSourceFile(outsf);
@ -604,20 +610,21 @@ cmLocalVisualStudio6Generator
const cmCustomCommand& command, const cmCustomCommand& command,
const char* flags) const char* flags)
{ {
std::string comment =
this->ConstructComment(command, "Building Custom Rule $(InputPath)");
if(comment == "<hack>")
{
comment = "";
}
// Write the rule for each configuration. // Write the rule for each configuration.
std::vector<std::string>::iterator i; std::vector<std::string>::iterator i;
for(i = this->Configurations.begin(); i != this->Configurations.end(); ++i) for(i = this->Configurations.begin(); i != this->Configurations.end(); ++i)
{ {
std::string config = this->GetConfigName(*i); std::string config = this->GetConfigName(*i);
cmCustomCommandGenerator ccg(command, config, this->Makefile);
std::string comment =
this->ConstructComment(ccg, "Building Custom Rule $(InputPath)");
if(comment == "<hack>")
{
comment = "";
}
std::string script = std::string script =
this->ConstructScript(command, config.c_str(), "\\\n\t"); this->ConstructScript(ccg, "\\\n\t");
if (i == this->Configurations.begin()) if (i == this->Configurations.begin())
{ {
@ -634,8 +641,8 @@ cmLocalVisualStudio6Generator
// Write out the dependencies for the rule. // Write out the dependencies for the rule.
fout << "USERDEP__HACK="; fout << "USERDEP__HACK=";
for(std::vector<std::string>::const_iterator d = for(std::vector<std::string>::const_iterator d =
command.GetDepends().begin(); ccg.GetDepends().begin();
d != command.GetDepends().end(); d != ccg.GetDepends().end();
++d) ++d)
{ {
// Lookup the real name of the dependency in case it is a CMake target. // Lookup the real name of the dependency in case it is a CMake target.
@ -655,7 +662,7 @@ cmLocalVisualStudio6Generator
fout << " " << comment.c_str(); fout << " " << comment.c_str();
} }
fout << "\n\n"; fout << "\n\n";
if(command.GetOutputs().empty()) if(ccg.GetOutputs().empty())
{ {
fout << source fout << source
<< "_force : \"$(SOURCE)\" \"$(INTDIR)\" \"$(OUTDIR)\"\n\t"; << "_force : \"$(SOURCE)\" \"$(INTDIR)\" \"$(OUTDIR)\"\n\t";
@ -664,8 +671,8 @@ cmLocalVisualStudio6Generator
else else
{ {
for(std::vector<std::string>::const_iterator o = for(std::vector<std::string>::const_iterator o =
command.GetOutputs().begin(); ccg.GetOutputs().begin();
o != command.GetOutputs().end(); o != ccg.GetOutputs().end();
++o) ++o)
{ {
// Write a rule for every output generated by this command. // Write a rule for every output generated by this command.

View File

@ -18,6 +18,7 @@
#include "cmSourceFile.h" #include "cmSourceFile.h"
#include "cmCacheManager.h" #include "cmCacheManager.h"
#include "cmGeneratorTarget.h" #include "cmGeneratorTarget.h"
#include "cmCustomCommandGenerator.h"
#include "cmake.h" #include "cmake.h"
#include "cmComputeLinkInformation.h" #include "cmComputeLinkInformation.h"
@ -609,9 +610,10 @@ public:
} }
void Write(cmCustomCommand const& cc) void Write(cmCustomCommand const& cc)
{ {
cmCustomCommandGenerator ccg(cc, this->Config, this->LG->GetMakefile());
if(this->First) if(this->First)
{ {
const char* comment = cc.GetComment(); const char* comment = ccg.GetComment();
if(comment && *comment) if(comment && *comment)
{ {
this->Stream << "\nDescription=\"" this->Stream << "\nDescription=\""
@ -624,7 +626,7 @@ public:
{ {
this->Stream << this->LG->EscapeForXML("\n"); this->Stream << this->LG->EscapeForXML("\n");
} }
std::string script = this->LG->ConstructScript(cc, this->Config); std::string script = this->LG->ConstructScript(ccg);
this->Stream << this->LG->EscapeForXML(script.c_str()); this->Stream << this->LG->EscapeForXML(script.c_str());
} }
private: private:
@ -1791,8 +1793,6 @@ WriteCustomRule(std::ostream& fout,
const cmCustomCommand& command, const cmCustomCommand& command,
FCInfo& fcinfo) FCInfo& fcinfo)
{ {
std::string comment = this->ConstructComment(command);
// Write the rule for each configuration. // Write the rule for each configuration.
std::vector<std::string>::iterator i; std::vector<std::string>::iterator i;
std::vector<std::string> *configs = std::vector<std::string> *configs =
@ -1810,6 +1810,7 @@ WriteCustomRule(std::ostream& fout,
} }
for(i = configs->begin(); i != configs->end(); ++i) for(i = configs->begin(); i != configs->end(); ++i)
{ {
cmCustomCommandGenerator ccg(command, *i, this->Makefile);
cmLVS7GFileConfig const& fc = fcinfo.FileConfigMap[*i]; cmLVS7GFileConfig const& fc = fcinfo.FileConfigMap[*i];
fout << "\t\t\t\t<FileConfiguration\n"; fout << "\t\t\t\t<FileConfiguration\n";
fout << "\t\t\t\t\tName=\"" << *i << "|" << this->PlatformName << "\">\n"; fout << "\t\t\t\t\tName=\"" << *i << "|" << this->PlatformName << "\">\n";
@ -1821,7 +1822,8 @@ WriteCustomRule(std::ostream& fout,
<< this->EscapeForXML(fc.CompileFlags.c_str()) << "\"/>\n"; << this->EscapeForXML(fc.CompileFlags.c_str()) << "\"/>\n";
} }
std::string script = this->ConstructScript(command, i->c_str()); std::string comment = this->ConstructComment(ccg);
std::string script = this->ConstructScript(ccg);
if(this->FortranProject) if(this->FortranProject)
{ {
cmSystemTools::ReplaceString(script, "$(Configuration)", i->c_str()); cmSystemTools::ReplaceString(script, "$(Configuration)", i->c_str());
@ -1833,7 +1835,7 @@ WriteCustomRule(std::ostream& fout,
<< "\t\t\t\t\tCommandLine=\"" << "\t\t\t\t\tCommandLine=\""
<< this->EscapeForXML(script.c_str()) << "\"\n" << this->EscapeForXML(script.c_str()) << "\"\n"
<< "\t\t\t\t\tAdditionalDependencies=\""; << "\t\t\t\t\tAdditionalDependencies=\"";
if(command.GetDepends().empty()) if(ccg.GetDepends().empty())
{ {
// There are no real dependencies. Produce an artificial one to // There are no real dependencies. Produce an artificial one to
// make sure the rule runs reliably. // make sure the rule runs reliably.
@ -1848,8 +1850,8 @@ WriteCustomRule(std::ostream& fout,
{ {
// Write out the dependencies for the rule. // Write out the dependencies for the rule.
for(std::vector<std::string>::const_iterator d = for(std::vector<std::string>::const_iterator d =
command.GetDepends().begin(); ccg.GetDepends().begin();
d != command.GetDepends().end(); d != ccg.GetDepends().end();
++d) ++d)
{ {
// Get the real name of the dependency in case it is a CMake target. // Get the real name of the dependency in case it is a CMake target.
@ -1863,7 +1865,7 @@ WriteCustomRule(std::ostream& fout,
} }
fout << "\"\n"; fout << "\"\n";
fout << "\t\t\t\t\tOutputs=\""; fout << "\t\t\t\t\tOutputs=\"";
if(command.GetOutputs().empty()) if(ccg.GetOutputs().empty())
{ {
fout << source << "_force"; fout << source << "_force";
} }
@ -1872,8 +1874,8 @@ WriteCustomRule(std::ostream& fout,
// Write a rule for the output generated by this command. // Write a rule for the output generated by this command.
const char* sep = ""; const char* sep = "";
for(std::vector<std::string>::const_iterator o = for(std::vector<std::string>::const_iterator o =
command.GetOutputs().begin(); ccg.GetOutputs().begin();
o != command.GetOutputs().end(); o != ccg.GetOutputs().end();
++o) ++o)
{ {
fout << sep << this->ConvertToXMLOutputPathSingle(o->c_str()); fout << sep << this->ConvertToXMLOutputPathSingle(o->c_str());

View File

@ -79,13 +79,11 @@ const char* cmLocalVisualStudioGenerator::GetReportErrorLabel() const
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
std::string std::string
cmLocalVisualStudioGenerator cmLocalVisualStudioGenerator
::ConstructScript(cmCustomCommand const& cc, ::ConstructScript(cmCustomCommandGenerator const& ccg,
const std::string& configName,
const std::string& newline_text) const std::string& newline_text)
{ {
bool useLocal = this->CustomCommandUseLocal(); bool useLocal = this->CustomCommandUseLocal();
std::string workingDirectory = cc.GetWorkingDirectory(); std::string workingDirectory = ccg.GetWorkingDirectory();
cmCustomCommandGenerator ccg(cc, configName, this->Makefile);
RelativeRoot relativeRoot = workingDirectory.empty()? START_OUTPUT : NONE; RelativeRoot relativeRoot = workingDirectory.empty()? START_OUTPUT : NONE;
// Avoid leading or trailing newlines. // Avoid leading or trailing newlines.

View File

@ -19,6 +19,7 @@
class cmSourceFile; class cmSourceFile;
class cmSourceGroup; class cmSourceGroup;
class cmCustomCommand; class cmCustomCommand;
class cmCustomCommandGenerator;
/** \class cmLocalVisualStudioGenerator /** \class cmLocalVisualStudioGenerator
* \brief Base class for Visual Studio generators. * \brief Base class for Visual Studio generators.
@ -46,8 +47,7 @@ public:
virtual ~cmLocalVisualStudioGenerator(); virtual ~cmLocalVisualStudioGenerator();
/** Construct a script from the given list of command lines. */ /** Construct a script from the given list of command lines. */
std::string ConstructScript(cmCustomCommand const& cc, std::string ConstructScript(cmCustomCommandGenerator const& ccg,
const std::string& configName,
const std::string& newline = "\n"); const std::string& newline = "\n");
/** Label to which to jump in a batch file after a failed step in a /** Label to which to jump in a batch file after a failed step in a

View File

@ -21,6 +21,7 @@
#include "cmTarget.h" #include "cmTarget.h"
#include "cmake.h" #include "cmake.h"
#include "cmComputeLinkInformation.h" #include "cmComputeLinkInformation.h"
#include "cmCustomCommandGenerator.h"
#include "cmGeneratorExpression.h" #include "cmGeneratorExpression.h"
#include "cmMakefileExecutableTargetGenerator.h" #include "cmMakefileExecutableTargetGenerator.h"
@ -158,11 +159,13 @@ void cmMakefileTargetGenerator::WriteTargetBuildRules()
si = customCommands.begin(); si = customCommands.begin();
si != customCommands.end(); ++si) si != customCommands.end(); ++si)
{ {
cmCustomCommand const* cc = (*si)->GetCustomCommand(); cmCustomCommandGenerator ccg(*(*si)->GetCustomCommand(),
this->GenerateCustomRuleFile(*cc); this->ConfigName,
this->Makefile);
this->GenerateCustomRuleFile(ccg);
if (clean) if (clean)
{ {
const std::vector<std::string>& outputs = cc->GetOutputs(); const std::vector<std::string>& outputs = ccg.GetOutputs();
for(std::vector<std::string>::const_iterator o = outputs.begin(); for(std::vector<std::string>::const_iterator o = outputs.begin();
o != outputs.end(); ++o) o != outputs.end(); ++o)
{ {
@ -1178,7 +1181,8 @@ cmMakefileTargetGenerator
{ {
if(cmCustomCommand* cc = (*source)->GetCustomCommand()) if(cmCustomCommand* cc = (*source)->GetCustomCommand())
{ {
const std::vector<std::string>& outputs = cc->GetOutputs(); cmCustomCommandGenerator ccg(*cc, this->ConfigName, this->Makefile);
const std::vector<std::string>& outputs = ccg.GetOutputs();
for(std::vector<std::string>::const_iterator o = outputs.begin(); for(std::vector<std::string>::const_iterator o = outputs.begin();
o != outputs.end(); ++o) o != outputs.end(); ++o)
{ {
@ -1210,11 +1214,11 @@ void cmMakefileTargetGenerator
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void cmMakefileTargetGenerator void cmMakefileTargetGenerator
::GenerateCustomRuleFile(const cmCustomCommand& cc) ::GenerateCustomRuleFile(cmCustomCommandGenerator const& ccg)
{ {
// Collect the commands. // Collect the commands.
std::vector<std::string> commands; std::vector<std::string> commands;
std::string comment = this->LocalGenerator->ConstructComment(cc); std::string comment = this->LocalGenerator->ConstructComment(ccg);
if(!comment.empty()) if(!comment.empty())
{ {
// add in a progress call if needed // add in a progress call if needed
@ -1229,19 +1233,19 @@ void cmMakefileTargetGenerator
// Now append the actual user-specified commands. // Now append the actual user-specified commands.
cmOStringStream content; cmOStringStream content;
this->LocalGenerator->AppendCustomCommand(commands, cc, this->Target, false, this->LocalGenerator->AppendCustomCommand(commands, ccg, this->Target, false,
cmLocalGenerator::HOME_OUTPUT, cmLocalGenerator::HOME_OUTPUT,
&content); &content);
// Collect the dependencies. // Collect the dependencies.
std::vector<std::string> depends; std::vector<std::string> depends;
this->LocalGenerator->AppendCustomDepend(depends, cc); this->LocalGenerator->AppendCustomDepend(depends, ccg);
// Check whether we need to bother checking for a symbolic output. // Check whether we need to bother checking for a symbolic output.
bool need_symbolic = this->GlobalGenerator->GetNeedSymbolicMark(); bool need_symbolic = this->GlobalGenerator->GetNeedSymbolicMark();
// Write the rule. // Write the rule.
const std::vector<std::string>& outputs = cc.GetOutputs(); const std::vector<std::string>& outputs = ccg.GetOutputs();
std::vector<std::string>::const_iterator o = outputs.begin(); std::vector<std::string>::const_iterator o = outputs.begin();
{ {
bool symbolic = false; bool symbolic = false;
@ -1259,7 +1263,7 @@ void cmMakefileTargetGenerator
// If the rule has changed make sure the output is rebuilt. // If the rule has changed make sure the output is rebuilt.
if(!symbolic) if(!symbolic)
{ {
this->GlobalGenerator->AddRuleHash(cc.GetOutputs(), content.str()); this->GlobalGenerator->AddRuleHash(ccg.GetOutputs(), content.str());
} }
} }
@ -1280,8 +1284,8 @@ void cmMakefileTargetGenerator
// Setup implicit dependency scanning. // Setup implicit dependency scanning.
for(cmCustomCommand::ImplicitDependsList::const_iterator for(cmCustomCommand::ImplicitDependsList::const_iterator
idi = cc.GetImplicitDepends().begin(); idi = ccg.GetCC().GetImplicitDepends().begin();
idi != cc.GetImplicitDepends().end(); ++idi) idi != ccg.GetCC().GetImplicitDepends().end(); ++idi)
{ {
std::string objFullPath = std::string objFullPath =
this->Convert(outputs[0], cmLocalGenerator::FULL); this->Convert(outputs[0], cmLocalGenerator::FULL);

View File

@ -15,7 +15,7 @@
#include "cmLocalUnixMakefileGenerator3.h" #include "cmLocalUnixMakefileGenerator3.h"
#include "cmOSXBundleGenerator.h" #include "cmOSXBundleGenerator.h"
class cmCustomCommand; class cmCustomCommandGenerator;
class cmDependInformation; class cmDependInformation;
class cmDepends; class cmDepends;
class cmGeneratorTarget; class cmGeneratorTarget;
@ -102,7 +102,7 @@ protected:
std::vector<std::string>& depends); std::vector<std::string>& depends);
// write the build rule for a custom command // write the build rule for a custom command
void GenerateCustomRuleFile(const cmCustomCommand& cc); void GenerateCustomRuleFile(cmCustomCommandGenerator const& ccg);
// write a rule to drive building of more than one output from // write a rule to drive building of more than one output from
// another rule // another rule

View File

@ -18,6 +18,7 @@
#include "cmMakefile.h" #include "cmMakefile.h"
#include "cmOSXBundleGenerator.h" #include "cmOSXBundleGenerator.h"
#include "cmGeneratorTarget.h" #include "cmGeneratorTarget.h"
#include "cmCustomCommandGenerator.h"
#include <assert.h> #include <assert.h>
#include <algorithm> #include <algorithm>
@ -555,7 +556,9 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
for (std::vector<cmCustomCommand>::const_iterator for (std::vector<cmCustomCommand>::const_iterator
ci = cmdLists[i]->begin(); ci = cmdLists[i]->begin();
ci != cmdLists[i]->end(); ++ci) { ci != cmdLists[i]->end(); ++ci) {
this->GetLocalGenerator()->AppendCustomCommandLines(&*ci, cmCustomCommandGenerator ccg(*ci, this->GetConfigName(),
this->GetMakefile());
this->GetLocalGenerator()->AppendCustomCommandLines(ccg,
*cmdLineLists[i]); *cmdLineLists[i]);
} }
} }

View File

@ -577,7 +577,9 @@ cmNinjaTargetGenerator
si != customCommands.end(); ++si) si != customCommands.end(); ++si)
{ {
cmCustomCommand const* cc = (*si)->GetCustomCommand(); cmCustomCommand const* cc = (*si)->GetCustomCommand();
const std::vector<std::string>& ccoutputs = cc->GetOutputs(); cmCustomCommandGenerator ccg(*cc, this->GetConfigName(),
this->GetMakefile());
const std::vector<std::string>& ccoutputs = ccg.GetOutputs();
std::transform(ccoutputs.begin(), ccoutputs.end(), std::transform(ccoutputs.begin(), ccoutputs.end(),
std::back_inserter(orderOnlyDeps), MapToNinjaPath()); std::back_inserter(orderOnlyDeps), MapToNinjaPath());
} }

View File

@ -17,6 +17,7 @@
#include "cmMakefile.h" #include "cmMakefile.h"
#include "cmSourceFile.h" #include "cmSourceFile.h"
#include "cmTarget.h" #include "cmTarget.h"
#include "cmCustomCommandGenerator.h"
cmNinjaUtilityTargetGenerator::cmNinjaUtilityTargetGenerator( cmNinjaUtilityTargetGenerator::cmNinjaUtilityTargetGenerator(
cmGeneratorTarget *target) cmGeneratorTarget *target)
@ -37,8 +38,10 @@ void cmNinjaUtilityTargetGenerator::Generate()
for (unsigned i = 0; i != 2; ++i) { for (unsigned i = 0; i != 2; ++i) {
for (std::vector<cmCustomCommand>::const_iterator for (std::vector<cmCustomCommand>::const_iterator
ci = cmdLists[i]->begin(); ci != cmdLists[i]->end(); ++ci) { ci = cmdLists[i]->begin(); ci != cmdLists[i]->end(); ++ci) {
this->GetLocalGenerator()->AppendCustomCommandDeps(&*ci, deps); cmCustomCommandGenerator ccg(*ci, this->GetConfigName(),
this->GetLocalGenerator()->AppendCustomCommandLines(&*ci, commands); this->GetMakefile());
this->GetLocalGenerator()->AppendCustomCommandDeps(ccg, deps);
this->GetLocalGenerator()->AppendCustomCommandLines(ccg, commands);
} }
} }
@ -49,10 +52,12 @@ void cmNinjaUtilityTargetGenerator::Generate()
{ {
if(cmCustomCommand* cc = (*source)->GetCustomCommand()) if(cmCustomCommand* cc = (*source)->GetCustomCommand())
{ {
cmCustomCommandGenerator ccg(*cc, this->GetConfigName(),
this->GetMakefile());
this->GetLocalGenerator()->AddCustomCommandTarget(cc, this->GetTarget()); this->GetLocalGenerator()->AddCustomCommandTarget(cc, this->GetTarget());
// Depend on all custom command outputs. // Depend on all custom command outputs.
const std::vector<std::string>& ccOutputs = cc->GetOutputs(); const std::vector<std::string>& ccOutputs = ccg.GetOutputs();
std::transform(ccOutputs.begin(), ccOutputs.end(), std::transform(ccOutputs.begin(), ccOutputs.end(),
std::back_inserter(deps), MapToNinjaPath()); std::back_inserter(deps), MapToNinjaPath());
} }

View File

@ -19,6 +19,7 @@
#include "cmSourceFile.h" #include "cmSourceFile.h"
#include "cmVisualStudioGeneratorOptions.h" #include "cmVisualStudioGeneratorOptions.h"
#include "cmLocalVisualStudio7Generator.h" #include "cmLocalVisualStudio7Generator.h"
#include "cmCustomCommandGenerator.h"
#include "cmVS10CLFlagTable.h" #include "cmVS10CLFlagTable.h"
#include "cmVS10LinkFlagTable.h" #include "cmVS10LinkFlagTable.h"
#include "cmVS10LibFlagTable.h" #include "cmVS10LibFlagTable.h"
@ -616,8 +617,6 @@ cmVisualStudio10TargetGenerator::WriteCustomRule(cmSourceFile* source,
} }
} }
cmLocalVisualStudio7Generator* lg = this->LocalGenerator; cmLocalVisualStudio7Generator* lg = this->LocalGenerator;
std::string comment = lg->ConstructComment(command);
comment = cmVS10EscapeComment(comment);
std::vector<std::string> *configs = std::vector<std::string> *configs =
static_cast<cmGlobalVisualStudio7Generator *> static_cast<cmGlobalVisualStudio7Generator *>
(this->GlobalGenerator)->GetConfigurations(); (this->GlobalGenerator)->GetConfigurations();
@ -627,8 +626,11 @@ cmVisualStudio10TargetGenerator::WriteCustomRule(cmSourceFile* source,
for(std::vector<std::string>::iterator i = configs->begin(); for(std::vector<std::string>::iterator i = configs->begin();
i != configs->end(); ++i) i != configs->end(); ++i)
{ {
cmCustomCommandGenerator ccg(command, *i, this->Makefile);
std::string comment = lg->ConstructComment(ccg);
comment = cmVS10EscapeComment(comment);
std::string script = std::string script =
cmVS10EscapeXML(lg->ConstructScript(command, i->c_str())); cmVS10EscapeXML(lg->ConstructScript(ccg));
this->WritePlatformConfigTag("Message",i->c_str(), 3); this->WritePlatformConfigTag("Message",i->c_str(), 3);
(*this->BuildFileStream ) << cmVS10EscapeXML(comment) << "</Message>\n"; (*this->BuildFileStream ) << cmVS10EscapeXML(comment) << "</Message>\n";
this->WritePlatformConfigTag("Command", i->c_str(), 3); this->WritePlatformConfigTag("Command", i->c_str(), 3);
@ -637,8 +639,8 @@ cmVisualStudio10TargetGenerator::WriteCustomRule(cmSourceFile* source,
(*this->BuildFileStream ) << source->GetFullPath(); (*this->BuildFileStream ) << source->GetFullPath();
for(std::vector<std::string>::const_iterator d = for(std::vector<std::string>::const_iterator d =
command.GetDepends().begin(); ccg.GetDepends().begin();
d != command.GetDepends().end(); d != ccg.GetDepends().end();
++d) ++d)
{ {
std::string dep; std::string dep;
@ -652,8 +654,8 @@ cmVisualStudio10TargetGenerator::WriteCustomRule(cmSourceFile* source,
this->WritePlatformConfigTag("Outputs", i->c_str(), 3); this->WritePlatformConfigTag("Outputs", i->c_str(), 3);
const char* sep = ""; const char* sep = "";
for(std::vector<std::string>::const_iterator o = for(std::vector<std::string>::const_iterator o =
command.GetOutputs().begin(); ccg.GetOutputs().begin();
o != command.GetOutputs().end(); o != ccg.GetOutputs().end();
++o) ++o)
{ {
std::string out = *o; std::string out = *o;
@ -1835,13 +1837,12 @@ void cmVisualStudio10TargetGenerator::WriteEvent(
for(std::vector<cmCustomCommand>::const_iterator i = commands.begin(); for(std::vector<cmCustomCommand>::const_iterator i = commands.begin();
i != commands.end(); ++i) i != commands.end(); ++i)
{ {
const cmCustomCommand& command = *i; cmCustomCommandGenerator ccg(*i, configName, this->Makefile);
comment += pre; comment += pre;
comment += lg->ConstructComment(command); comment += lg->ConstructComment(ccg);
script += pre; script += pre;
pre = "\n"; pre = "\n";
script += script += cmVS10EscapeXML(lg->ConstructScript(ccg));
cmVS10EscapeXML(lg->ConstructScript(command, configName.c_str()));
} }
comment = cmVS10EscapeComment(comment); comment = cmVS10EscapeComment(comment);
this->WriteString("<Message>",3); this->WriteString("<Message>",3);