ENH: separate command from its arguments in the custom command. This allows the generator on windows to change the slashes for just the command
This commit is contained in:
parent
ecff0d36ac
commit
cc5c1fa6f7
|
@ -53,25 +53,32 @@ bool cmAddCustomTargetCommand::InitialPass(std::vector<std::string>& args)
|
||||||
m_Makefile->ExpandVariablesInString(args[0]);
|
m_Makefile->ExpandVariablesInString(args[0]);
|
||||||
|
|
||||||
// all target option
|
// all target option
|
||||||
std::string result;
|
std::string arguments;
|
||||||
std::vector<std::string>::iterator s = args.begin();
|
std::vector<std::string>::iterator s = args.begin();
|
||||||
++s;
|
++s; // move past args[0] as it is already to be used
|
||||||
if (args.size() >= 3)
|
if (args.size() >= 3)
|
||||||
{
|
{
|
||||||
if (args[1] == "ALL")
|
if (args[1] == "ALL")
|
||||||
{
|
{
|
||||||
all = true;
|
all = true;
|
||||||
++s;
|
++s; // skip all
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
std::string command;
|
||||||
|
if(s != args.end())
|
||||||
|
{
|
||||||
|
command = m_Makefile->ExpandVariablesInString(*s);
|
||||||
|
++s;
|
||||||
|
}
|
||||||
for (;s != args.end(); ++s)
|
for (;s != args.end(); ++s)
|
||||||
{
|
{
|
||||||
m_Makefile->ExpandVariablesInString(*s);
|
m_Makefile->ExpandVariablesInString(*s);
|
||||||
result += cmSystemTools::EscapeSpaces(s->c_str());
|
arguments += cmSystemTools::EscapeSpaces(s->c_str());
|
||||||
result += " ";
|
arguments += " ";
|
||||||
}
|
}
|
||||||
m_Makefile->AddUtilityCommand(args[0].c_str(),
|
m_Makefile->AddUtilityCommand(args[0].c_str(),
|
||||||
result.c_str(), all);
|
command.c_str(),
|
||||||
|
arguments.c_str(), all);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,10 +45,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
* The constructor
|
* The constructor
|
||||||
*/
|
*/
|
||||||
cmCustomCommand::cmCustomCommand(const char *src, const char *command,
|
cmCustomCommand::cmCustomCommand(const char *src, const char *command,
|
||||||
|
const char* arguments,
|
||||||
std::vector<std::string> dep,
|
std::vector<std::string> dep,
|
||||||
std::vector<std::string> out):
|
std::vector<std::string> out):
|
||||||
m_Source(src),
|
m_Source(src),
|
||||||
m_Command(command),
|
m_Command(command),
|
||||||
|
m_Arguments(arguments),
|
||||||
m_Depends(dep),
|
m_Depends(dep),
|
||||||
m_Outputs(out)
|
m_Outputs(out)
|
||||||
{
|
{
|
||||||
|
@ -61,6 +63,7 @@ cmCustomCommand::cmCustomCommand(const char *src, const char *command,
|
||||||
cmCustomCommand::cmCustomCommand(const cmCustomCommand& r):
|
cmCustomCommand::cmCustomCommand(const cmCustomCommand& r):
|
||||||
m_Source(r.m_Source),
|
m_Source(r.m_Source),
|
||||||
m_Command(r.m_Command),
|
m_Command(r.m_Command),
|
||||||
|
m_Arguments(r.m_Arguments),
|
||||||
m_Depends(r.m_Depends),
|
m_Depends(r.m_Depends),
|
||||||
m_Outputs(r.m_Outputs)
|
m_Outputs(r.m_Outputs)
|
||||||
{
|
{
|
||||||
|
@ -70,6 +73,7 @@ void cmCustomCommand::ExpandVariables(const cmMakefile &mf)
|
||||||
{
|
{
|
||||||
mf.ExpandVariablesInString(m_Source);
|
mf.ExpandVariablesInString(m_Source);
|
||||||
mf.ExpandVariablesInString(m_Command);
|
mf.ExpandVariablesInString(m_Command);
|
||||||
|
mf.ExpandVariablesInString(m_Arguments);
|
||||||
|
|
||||||
for (std::vector<std::string>::iterator i = m_Depends.begin();
|
for (std::vector<std::string>::iterator i = m_Depends.begin();
|
||||||
i != m_Depends.end(); ++i)
|
i != m_Depends.end(); ++i)
|
||||||
|
|
|
@ -53,6 +53,7 @@ class cmCustomCommand
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
cmCustomCommand(const char *src, const char *command,
|
cmCustomCommand(const char *src, const char *command,
|
||||||
|
const char* arguments,
|
||||||
std::vector<std::string> dep,
|
std::vector<std::string> dep,
|
||||||
std::vector<std::string> out);
|
std::vector<std::string> out);
|
||||||
cmCustomCommand(const cmCustomCommand& r);
|
cmCustomCommand(const cmCustomCommand& r);
|
||||||
|
@ -69,11 +70,17 @@ public:
|
||||||
std::string GetSourceName() const {return m_Source;}
|
std::string GetSourceName() const {return m_Source;}
|
||||||
void SetSourceName(const char *name) {m_Source = name;}
|
void SetSourceName(const char *name) {m_Source = name;}
|
||||||
|
|
||||||
/**
|
///! Return the command to execute with arguments
|
||||||
* Return the command to execute
|
std::string GetCommandAndArguments() const
|
||||||
*/
|
{return m_Command + " " + m_Arguments;}
|
||||||
|
|
||||||
|
///! Return the command to execute
|
||||||
std::string GetCommand() const {return m_Command;}
|
std::string GetCommand() const {return m_Command;}
|
||||||
void SetCommand(const char *cmd) {m_Command = cmd;}
|
void SetCommand(const char *cmd) {m_Command = cmd;}
|
||||||
|
|
||||||
|
///! Return the commands arguments
|
||||||
|
std::string GetArguments() const {return m_Arguments;}
|
||||||
|
void SetArguments(const char *arg) {m_Arguments = arg;}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the vector that holds the list of dependencies
|
* Return the vector that holds the list of dependencies
|
||||||
|
@ -90,6 +97,7 @@ public:
|
||||||
private:
|
private:
|
||||||
std::string m_Source;
|
std::string m_Source;
|
||||||
std::string m_Command;
|
std::string m_Command;
|
||||||
|
std::string m_Arguments;
|
||||||
std::vector<std::string> m_Depends;
|
std::vector<std::string> m_Depends;
|
||||||
std::vector<std::string> m_Outputs;
|
std::vector<std::string> m_Outputs;
|
||||||
};
|
};
|
||||||
|
|
|
@ -152,21 +152,22 @@ void cmDSPWriter::AddDSPBuildRule(cmSourceGroup& sourceGroup)
|
||||||
std::string dsprule = "${CMAKE_COMMAND} ";
|
std::string dsprule = "${CMAKE_COMMAND} ";
|
||||||
m_Makefile->ExpandVariablesInString(dsprule);
|
m_Makefile->ExpandVariablesInString(dsprule);
|
||||||
dsprule = cmSystemTools::HandleNetworkPaths(dsprule.c_str());
|
dsprule = cmSystemTools::HandleNetworkPaths(dsprule.c_str());
|
||||||
dsprule += makefileIn;
|
std::string args = makefileIn;
|
||||||
dsprule += " -DSP -H\"";
|
args += " -DSP -H\"";
|
||||||
dsprule += cmSystemTools::HandleNetworkPaths(m_Makefile->GetHomeDirectory());
|
args += cmSystemTools::HandleNetworkPaths(m_Makefile->GetHomeDirectory());
|
||||||
dsprule += "\" -S\"";
|
args += "\" -S\"";
|
||||||
dsprule += cmSystemTools::HandleNetworkPaths(m_Makefile->GetStartDirectory());
|
args += cmSystemTools::HandleNetworkPaths(m_Makefile->GetStartDirectory());
|
||||||
dsprule += "\" -O\"";
|
args += "\" -O\"";
|
||||||
dsprule += cmSystemTools::HandleNetworkPaths(m_Makefile->GetStartOutputDirectory());
|
args += cmSystemTools::HandleNetworkPaths(m_Makefile->GetStartOutputDirectory());
|
||||||
dsprule += "\" -B\"";
|
args += "\" -B\"";
|
||||||
dsprule += cmSystemTools::HandleNetworkPaths(m_Makefile->GetHomeOutputDirectory());
|
args += cmSystemTools::HandleNetworkPaths(m_Makefile->GetHomeOutputDirectory());
|
||||||
dsprule += "\"";
|
args += "\"";
|
||||||
m_Makefile->ExpandVariablesInString(dsprule);
|
m_Makefile->ExpandVariablesInString(args);
|
||||||
|
|
||||||
std::vector<std::string> outputs;
|
std::vector<std::string> outputs;
|
||||||
outputs.push_back(dspname);
|
outputs.push_back(dspname);
|
||||||
cmCustomCommand cc(makefileIn.c_str(), dsprule.c_str(),
|
cmCustomCommand cc(makefileIn.c_str(), dsprule.c_str(),
|
||||||
|
args.c_str(),
|
||||||
m_Makefile->GetListFiles(),
|
m_Makefile->GetListFiles(),
|
||||||
outputs);
|
outputs);
|
||||||
sourceGroup.AddCustomCommand(cc);
|
sourceGroup.AddCustomCommand(cc);
|
||||||
|
@ -263,9 +264,11 @@ void cmDSPWriter::WriteDSPFile(std::ostream& fout,
|
||||||
c != commands.end(); ++c)
|
c != commands.end(); ++c)
|
||||||
{
|
{
|
||||||
totalCommandStr += "\n\t";
|
totalCommandStr += "\n\t";
|
||||||
temp= c->first;
|
temp= c->second.m_Command;
|
||||||
cmSystemTools::ConvertToWindowsSlashes(temp);
|
cmSystemTools::ConvertToWindowsSlashes(temp);
|
||||||
totalCommandStr += temp;
|
totalCommandStr += temp;
|
||||||
|
totalCommandStr += " ";
|
||||||
|
totalCommandStr += c->second.m_Arguments;
|
||||||
totalCommand.Merge(c->second);
|
totalCommand.Merge(c->second);
|
||||||
}
|
}
|
||||||
// Create a dummy file with the name of the source if it does
|
// Create a dummy file with the name of the source if it does
|
||||||
|
|
|
@ -102,7 +102,8 @@ void cmDSWWriter::WriteDSWFile(std::ostream& fout)
|
||||||
allListFiles.push_back(m_Makefile);
|
allListFiles.push_back(m_Makefile);
|
||||||
// add a special target that depends on ALL projects for easy build
|
// add a special target that depends on ALL projects for easy build
|
||||||
// of Debug only
|
// of Debug only
|
||||||
m_Makefile->AddUtilityCommand("ALL_BUILD", "echo \"Build all projects\"", false);
|
m_Makefile->AddUtilityCommand("ALL_BUILD", "echo", "\"Build all projects\"",
|
||||||
|
false);
|
||||||
m_Makefile->FindSubDirectoryCMakeListsFiles(allListFiles);
|
m_Makefile->FindSubDirectoryCMakeListsFiles(allListFiles);
|
||||||
// For each cmMakefile, create a DSP for it, and
|
// For each cmMakefile, create a DSP for it, and
|
||||||
// add it to this DSW file
|
// add it to this DSW file
|
||||||
|
|
|
@ -470,9 +470,7 @@ void cmMakefile::AddCustomCommand(const char* source,
|
||||||
if (m_Targets.find(target) != m_Targets.end())
|
if (m_Targets.find(target) != m_Targets.end())
|
||||||
{
|
{
|
||||||
std::string c = cmSystemTools::EscapeSpaces(command);
|
std::string c = cmSystemTools::EscapeSpaces(command);
|
||||||
c += " ";
|
cmCustomCommand cc(source,c.c_str(),commandArgs,depends,outputs);
|
||||||
c += commandArgs;
|
|
||||||
cmCustomCommand cc(source,c.c_str(),depends,outputs);
|
|
||||||
m_Targets[target].GetCustomCommands().push_back(cc);
|
m_Targets[target].GetCustomCommands().push_back(cc);
|
||||||
std::string cacheCommand = command;
|
std::string cacheCommand = command;
|
||||||
this->ExpandVariablesInString(cacheCommand);
|
this->ExpandVariablesInString(cacheCommand);
|
||||||
|
@ -707,15 +705,17 @@ void cmMakefile::AddExecutable(const char *exeName,
|
||||||
|
|
||||||
void cmMakefile::AddUtilityCommand(const char* utilityName,
|
void cmMakefile::AddUtilityCommand(const char* utilityName,
|
||||||
const char* command,
|
const char* command,
|
||||||
|
const char* arguments,
|
||||||
bool all)
|
bool all)
|
||||||
{
|
{
|
||||||
std::vector<std::string> empty;
|
std::vector<std::string> empty;
|
||||||
this->AddUtilityCommand(utilityName,command,all,
|
this->AddUtilityCommand(utilityName,command,arguments,all,
|
||||||
empty,empty);
|
empty,empty);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmMakefile::AddUtilityCommand(const char* utilityName,
|
void cmMakefile::AddUtilityCommand(const char* utilityName,
|
||||||
const char* command,
|
const char* command,
|
||||||
|
const char* arguments,
|
||||||
bool all,
|
bool all,
|
||||||
const std::vector<std::string> &dep,
|
const std::vector<std::string> &dep,
|
||||||
const std::vector<std::string> &out)
|
const std::vector<std::string> &out)
|
||||||
|
@ -723,7 +723,7 @@ void cmMakefile::AddUtilityCommand(const char* utilityName,
|
||||||
cmTarget target;
|
cmTarget target;
|
||||||
target.SetType(cmTarget::UTILITY);
|
target.SetType(cmTarget::UTILITY);
|
||||||
target.SetInAll(all);
|
target.SetInAll(all);
|
||||||
cmCustomCommand cc(utilityName, command, dep, out);
|
cmCustomCommand cc(utilityName, command, arguments, dep, out);
|
||||||
target.GetCustomCommands().push_back(cc);
|
target.GetCustomCommands().push_back(cc);
|
||||||
m_Targets.insert(cmTargets::value_type(utilityName,target));
|
m_Targets.insert(cmTargets::value_type(utilityName,target));
|
||||||
}
|
}
|
||||||
|
|
|
@ -167,9 +167,11 @@ public:
|
||||||
*/
|
*/
|
||||||
void AddUtilityCommand(const char* utilityName,
|
void AddUtilityCommand(const char* utilityName,
|
||||||
const char* command,
|
const char* command,
|
||||||
|
const char* arguments,
|
||||||
bool all);
|
bool all);
|
||||||
void AddUtilityCommand(const char* utilityName,
|
void AddUtilityCommand(const char* utilityName,
|
||||||
const char* command,
|
const char* command,
|
||||||
|
const char* arguments,
|
||||||
bool all,
|
bool all,
|
||||||
const std::vector<std::string> &depends,
|
const std::vector<std::string> &depends,
|
||||||
const std::vector<std::string> &outputs);
|
const std::vector<std::string> &outputs);
|
||||||
|
|
|
@ -94,32 +94,40 @@ void cmSourceGroup::AddSource(const char* name)
|
||||||
*/
|
*/
|
||||||
void cmSourceGroup::AddCustomCommand(const cmCustomCommand &cmd)
|
void cmSourceGroup::AddCustomCommand(const cmCustomCommand &cmd)
|
||||||
{
|
{
|
||||||
|
std::string commandAndArgs = cmd.GetCommandAndArguments();
|
||||||
BuildRules::iterator s = m_BuildRules.find(cmd.GetSourceName());
|
BuildRules::iterator s = m_BuildRules.find(cmd.GetSourceName());
|
||||||
if(s == m_BuildRules.end())
|
if(s == m_BuildRules.end())
|
||||||
{
|
{
|
||||||
// The source was not found. Add it with this command.
|
// The source was not found. Add it with this command.
|
||||||
m_BuildRules[cmd.GetSourceName()][cmd.GetCommand()].
|
CommandFiles& cmdFiles = m_BuildRules[cmd.GetSourceName()][commandAndArgs];
|
||||||
m_Depends.insert(cmd.GetDepends().begin(),cmd.GetDepends().end());
|
cmdFiles.m_Command = cmd.GetCommand();
|
||||||
m_BuildRules[cmd.GetSourceName()][cmd.GetCommand()].
|
cmdFiles.m_Arguments = cmd.GetArguments();
|
||||||
m_Outputs.insert(cmd.GetOutputs().begin(),cmd.GetOutputs().end());
|
cmdFiles.m_Depends.insert(cmd.GetDepends().begin(),cmd.GetDepends().end());
|
||||||
|
cmdFiles.m_Outputs.insert(cmd.GetOutputs().begin(),cmd.GetOutputs().end());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// The source already exists. See if the command exists.
|
// The source already exists. See if the command exists.
|
||||||
Commands& commands = s->second;
|
Commands& commands = s->second;
|
||||||
Commands::iterator c = commands.find(cmd.GetCommand());
|
Commands::iterator c = commands.find(commandAndArgs);
|
||||||
if(c == commands.end())
|
if(c == commands.end())
|
||||||
{
|
{
|
||||||
// The command did not exist. Add it.
|
// The command did not exist. Add it.
|
||||||
commands[cmd.GetCommand()].m_Depends.insert(cmd.GetDepends().begin(), cmd.GetDepends().end());
|
commands[commandAndArgs].m_Command = cmd.GetCommand();
|
||||||
commands[cmd.GetCommand()].m_Outputs.insert(cmd.GetOutputs().begin(), cmd.GetOutputs().end());
|
commands[commandAndArgs].m_Arguments = cmd.GetArguments();
|
||||||
|
commands[commandAndArgs].m_Depends.insert(cmd.GetDepends().begin(),
|
||||||
|
cmd.GetDepends().end());
|
||||||
|
commands[commandAndArgs].m_Outputs.insert(cmd.GetOutputs().begin(),
|
||||||
|
cmd.GetOutputs().end());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// The command already exists for this source. Merge the sets.
|
// The command already exists for this source. Merge the sets.
|
||||||
CommandFiles& commandFiles = c->second;
|
CommandFiles& commandFiles = c->second;
|
||||||
commandFiles.m_Depends.insert(cmd.GetDepends().begin(), cmd.GetDepends().end());
|
commandFiles.m_Depends.insert(cmd.GetDepends().begin(),
|
||||||
commandFiles.m_Outputs.insert(cmd.GetOutputs().begin(), cmd.GetOutputs().end());
|
cmd.GetDepends().end());
|
||||||
|
commandFiles.m_Outputs.insert(cmd.GetOutputs().begin(),
|
||||||
|
cmd.GetOutputs().end());
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmSourceGroup::Print() const
|
void cmSourceGroup::Print() const
|
||||||
|
@ -132,7 +140,9 @@ void cmSourceGroup::Print() const
|
||||||
for(Commands::const_iterator j = i->second.begin();
|
for(Commands::const_iterator j = i->second.begin();
|
||||||
j != i->second.end(); ++j)
|
j != i->second.end(); ++j)
|
||||||
{
|
{
|
||||||
std::cout << "Command: " << j->first.c_str() << "\n";
|
std::cout << "FullCommand: " << j->first.c_str() << "\n";
|
||||||
|
std::cout << "Command: " << j->second.m_Command.c_str() << "\n";
|
||||||
|
std::cout << "Arguments: " << j->second.m_Arguments.c_str() << "\n";
|
||||||
std::cout << "Command Outputs " << j->second.m_Outputs.size() << "\n";
|
std::cout << "Command Outputs " << j->second.m_Outputs.size() << "\n";
|
||||||
std::cout << "Command Depends " << j->second.m_Depends.size() << "\n";
|
std::cout << "Command Depends " << j->second.m_Depends.size() << "\n";
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,6 +67,8 @@ public:
|
||||||
|
|
||||||
void Merge(const CommandFiles &r);
|
void Merge(const CommandFiles &r);
|
||||||
|
|
||||||
|
std::string m_Command;
|
||||||
|
std::string m_Arguments;
|
||||||
std::set<std::string> m_Outputs;
|
std::set<std::string> m_Outputs;
|
||||||
std::set<std::string> m_Depends;
|
std::set<std::string> m_Depends;
|
||||||
};
|
};
|
||||||
|
|
|
@ -139,6 +139,7 @@ void cmVTKWrapJavaCommand::FinalPass()
|
||||||
}
|
}
|
||||||
|
|
||||||
m_Makefile->AddUtilityCommand((m_LibraryName+"JavaClasses").c_str(),
|
m_Makefile->AddUtilityCommand((m_LibraryName+"JavaClasses").c_str(),
|
||||||
|
"",
|
||||||
"",
|
"",
|
||||||
true,
|
true,
|
||||||
alldepends,
|
alldepends,
|
||||||
|
|
Loading…
Reference in New Issue