Simplify VS generator ConstructScript interface

Pass to cmLocalVisualStudioGenerator::ConstructScript a cmCustomCommand
instance instead of extracting arguments at all call sites.
This commit is contained in:
Brad King 2010-12-07 13:44:54 -05:00
parent ced1d5eccd
commit 6fe5b3db0b
5 changed files with 14 additions and 47 deletions

View File

@ -65,13 +65,7 @@ public:
{
this->Code += "\\\n\t";
}
this->Code +=
this->LG->ConstructScript(cc.GetCommandLines(),
cc.GetWorkingDirectory(),
this->Config,
cc.GetEscapeOldStyle(),
cc.GetEscapeAllowMakeVars(),
"\\\n\t");
this->Code += this->LG->ConstructScript(cc, this->Config, "\\\n\t");
}
private:
cmLocalVisualStudio6Generator* LG;
@ -659,12 +653,7 @@ cmLocalVisualStudio6Generator
{
std::string config = this->GetConfigName(*i);
std::string script =
this->ConstructScript(command.GetCommandLines(),
command.GetWorkingDirectory(),
config.c_str(),
command.GetEscapeOldStyle(),
command.GetEscapeAllowMakeVars(),
"\\\n\t");
this->ConstructScript(command, config.c_str(), "\\\n\t");
if (i == this->Configurations.begin())
{

View File

@ -546,12 +546,7 @@ public:
{
this->Stream << this->LG->EscapeForXML("\n");
}
std::string script =
this->LG->ConstructScript(cc.GetCommandLines(),
cc.GetWorkingDirectory(),
this->Config,
cc.GetEscapeOldStyle(),
cc.GetEscapeAllowMakeVars());
std::string script = this->LG->ConstructScript(cc, this->Config);
this->Stream << this->LG->EscapeForXML(script.c_str());
}
private:
@ -1591,12 +1586,7 @@ WriteCustomRule(std::ostream& fout,
<< this->EscapeForXML(fc.CompileFlags.c_str()) << "\"/>\n";
}
std::string script =
this->ConstructScript(command.GetCommandLines(),
command.GetWorkingDirectory(),
i->c_str(),
command.GetEscapeOldStyle(),
command.GetEscapeAllowMakeVars());
std::string script = this->ConstructScript(command, i->c_str());
fout << "\t\t\t\t\t<Tool\n"
<< "\t\t\t\t\tName=\"" << customTool << "\"\n"
<< "\t\t\t\t\tDescription=\""

View File

@ -151,13 +151,15 @@ void cmLocalVisualStudioGenerator::ComputeObjectNameRequirements
//----------------------------------------------------------------------------
std::string
cmLocalVisualStudioGenerator
::ConstructScript(const cmCustomCommandLines& commandLines,
const char* workingDirectory,
::ConstructScript(cmCustomCommand const& cc,
const char* configName,
bool escapeOldStyle,
bool escapeAllowMakeVars,
const char* newline_text)
{
const cmCustomCommandLines& commandLines = cc.GetCommandLines();
const char* workingDirectory = cc.GetWorkingDirectory();
bool escapeOldStyle = cc.GetEscapeOldStyle();
bool escapeAllowMakeVars = cc.GetEscapeAllowMakeVars();
// Avoid leading or trailing newlines.
const char* newline = "";

View File

@ -18,6 +18,7 @@
class cmSourceFile;
class cmSourceGroup;
class cmCustomCommand;
/** \class cmLocalVisualStudioGenerator
* \brief Base class for Visual Studio generators.
@ -31,11 +32,8 @@ public:
cmLocalVisualStudioGenerator();
virtual ~cmLocalVisualStudioGenerator();
/** Construct a script from the given list of command lines. */
std::string ConstructScript(const cmCustomCommandLines& commandLines,
const char* workingDirectory,
std::string ConstructScript(cmCustomCommand const& cc,
const char* configName,
bool escapeOldStyle,
bool escapeAllowMakeVars,
const char* newline = "\n");
protected:

View File

@ -367,13 +367,7 @@ cmVisualStudio10TargetGenerator::WriteCustomRule(cmSourceFile* source,
i != configs->end(); ++i)
{
std::string script =
cmVS10EscapeXML(
lg->ConstructScript(command.GetCommandLines(),
command.GetWorkingDirectory(),
i->c_str(),
command.GetEscapeOldStyle(),
command.GetEscapeAllowMakeVars())
);
cmVS10EscapeXML(lg->ConstructScript(command, i->c_str()));
this->WritePlatformConfigTag("Message",i->c_str(), 3);
(*this->BuildFileStream ) << cmVS10EscapeXML(comment) << "</Message>\n";
this->WritePlatformConfigTag("Command", i->c_str(), 3);
@ -1460,13 +1454,7 @@ void cmVisualStudio10TargetGenerator::WriteEvent(
script += pre;
pre = "\n";
script +=
cmVS10EscapeXML(
lg->ConstructScript(command.GetCommandLines(),
command.GetWorkingDirectory(),
configName.c_str(),
command.GetEscapeOldStyle(),
command.GetEscapeAllowMakeVars())
);
cmVS10EscapeXML(lg->ConstructScript(command, configName.c_str()));
}
comment = cmVS10EscapeComment(comment);
this->WriteString("<Message>",3);