mirror of
https://github.com/Kitware/CMake.git
synced 2026-03-03 05:08:47 -06:00
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:
@@ -18,6 +18,7 @@
|
||||
#include "cmSourceFile.h"
|
||||
#include "cmCacheManager.h"
|
||||
#include "cmGeneratorTarget.h"
|
||||
#include "cmCustomCommandGenerator.h"
|
||||
#include "cmake.h"
|
||||
|
||||
#include "cmComputeLinkInformation.h"
|
||||
@@ -609,9 +610,10 @@ public:
|
||||
}
|
||||
void Write(cmCustomCommand const& cc)
|
||||
{
|
||||
cmCustomCommandGenerator ccg(cc, this->Config, this->LG->GetMakefile());
|
||||
if(this->First)
|
||||
{
|
||||
const char* comment = cc.GetComment();
|
||||
const char* comment = ccg.GetComment();
|
||||
if(comment && *comment)
|
||||
{
|
||||
this->Stream << "\nDescription=\""
|
||||
@@ -624,7 +626,7 @@ public:
|
||||
{
|
||||
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());
|
||||
}
|
||||
private:
|
||||
@@ -1791,8 +1793,6 @@ WriteCustomRule(std::ostream& fout,
|
||||
const cmCustomCommand& command,
|
||||
FCInfo& fcinfo)
|
||||
{
|
||||
std::string comment = this->ConstructComment(command);
|
||||
|
||||
// Write the rule for each configuration.
|
||||
std::vector<std::string>::iterator i;
|
||||
std::vector<std::string> *configs =
|
||||
@@ -1810,6 +1810,7 @@ WriteCustomRule(std::ostream& fout,
|
||||
}
|
||||
for(i = configs->begin(); i != configs->end(); ++i)
|
||||
{
|
||||
cmCustomCommandGenerator ccg(command, *i, this->Makefile);
|
||||
cmLVS7GFileConfig const& fc = fcinfo.FileConfigMap[*i];
|
||||
fout << "\t\t\t\t<FileConfiguration\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";
|
||||
}
|
||||
|
||||
std::string script = this->ConstructScript(command, i->c_str());
|
||||
std::string comment = this->ConstructComment(ccg);
|
||||
std::string script = this->ConstructScript(ccg);
|
||||
if(this->FortranProject)
|
||||
{
|
||||
cmSystemTools::ReplaceString(script, "$(Configuration)", i->c_str());
|
||||
@@ -1833,7 +1835,7 @@ WriteCustomRule(std::ostream& fout,
|
||||
<< "\t\t\t\t\tCommandLine=\""
|
||||
<< this->EscapeForXML(script.c_str()) << "\"\n"
|
||||
<< "\t\t\t\t\tAdditionalDependencies=\"";
|
||||
if(command.GetDepends().empty())
|
||||
if(ccg.GetDepends().empty())
|
||||
{
|
||||
// There are no real dependencies. Produce an artificial one to
|
||||
// make sure the rule runs reliably.
|
||||
@@ -1848,8 +1850,8 @@ WriteCustomRule(std::ostream& fout,
|
||||
{
|
||||
// Write out the dependencies for the rule.
|
||||
for(std::vector<std::string>::const_iterator d =
|
||||
command.GetDepends().begin();
|
||||
d != command.GetDepends().end();
|
||||
ccg.GetDepends().begin();
|
||||
d != ccg.GetDepends().end();
|
||||
++d)
|
||||
{
|
||||
// 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 << "\t\t\t\t\tOutputs=\"";
|
||||
if(command.GetOutputs().empty())
|
||||
if(ccg.GetOutputs().empty())
|
||||
{
|
||||
fout << source << "_force";
|
||||
}
|
||||
@@ -1872,8 +1874,8 @@ WriteCustomRule(std::ostream& fout,
|
||||
// Write a rule for the output generated by this command.
|
||||
const char* sep = "";
|
||||
for(std::vector<std::string>::const_iterator o =
|
||||
command.GetOutputs().begin();
|
||||
o != command.GetOutputs().end();
|
||||
ccg.GetOutputs().begin();
|
||||
o != ccg.GetOutputs().end();
|
||||
++o)
|
||||
{
|
||||
fout << sep << this->ConvertToXMLOutputPathSingle(o->c_str());
|
||||
|
||||
Reference in New Issue
Block a user