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

View File

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

View File

@ -151,13 +151,15 @@ void cmLocalVisualStudioGenerator::ComputeObjectNameRequirements
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
std::string std::string
cmLocalVisualStudioGenerator cmLocalVisualStudioGenerator
::ConstructScript(const cmCustomCommandLines& commandLines, ::ConstructScript(cmCustomCommand const& cc,
const char* workingDirectory,
const char* configName, const char* configName,
bool escapeOldStyle,
bool escapeAllowMakeVars,
const char* newline_text) 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. // Avoid leading or trailing newlines.
const char* newline = ""; const char* newline = "";

View File

@ -18,6 +18,7 @@
class cmSourceFile; class cmSourceFile;
class cmSourceGroup; class cmSourceGroup;
class cmCustomCommand;
/** \class cmLocalVisualStudioGenerator /** \class cmLocalVisualStudioGenerator
* \brief Base class for Visual Studio generators. * \brief Base class for Visual Studio generators.
@ -31,11 +32,8 @@ public:
cmLocalVisualStudioGenerator(); cmLocalVisualStudioGenerator();
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(const cmCustomCommandLines& commandLines, std::string ConstructScript(cmCustomCommand const& cc,
const char* workingDirectory,
const char* configName, const char* configName,
bool escapeOldStyle,
bool escapeAllowMakeVars,
const char* newline = "\n"); const char* newline = "\n");
protected: protected:

View File

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