diff options
-rw-r--r-- | Source/cmAddCustomTargetCommand.cxx | 19 | ||||
-rw-r--r-- | Source/cmCustomCommand.cxx | 4 | ||||
-rw-r--r-- | Source/cmCustomCommand.h | 14 | ||||
-rw-r--r-- | Source/cmDSPWriter.cxx | 27 | ||||
-rw-r--r-- | Source/cmDSWWriter.cxx | 3 | ||||
-rw-r--r-- | Source/cmMakefile.cxx | 10 | ||||
-rw-r--r-- | Source/cmMakefile.h | 2 | ||||
-rw-r--r-- | Source/cmSourceGroup.cxx | 30 | ||||
-rw-r--r-- | Source/cmSourceGroup.h | 2 | ||||
-rw-r--r-- | Source/cmVTKWrapJavaCommand.cxx | 1 |
10 files changed, 75 insertions, 37 deletions
diff --git a/Source/cmAddCustomTargetCommand.cxx b/Source/cmAddCustomTargetCommand.cxx index 6320ba6..070c1af 100644 --- a/Source/cmAddCustomTargetCommand.cxx +++ b/Source/cmAddCustomTargetCommand.cxx @@ -53,25 +53,32 @@ bool cmAddCustomTargetCommand::InitialPass(std::vector<std::string>& args) m_Makefile->ExpandVariablesInString(args[0]); // all target option - std::string result; + std::string arguments; 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[1] == "ALL") { all = true; - ++s; + ++s; // skip all } } + std::string command; + if(s != args.end()) + { + command = m_Makefile->ExpandVariablesInString(*s); + ++s; + } for (;s != args.end(); ++s) { m_Makefile->ExpandVariablesInString(*s); - result += cmSystemTools::EscapeSpaces(s->c_str()); - result += " "; + arguments += cmSystemTools::EscapeSpaces(s->c_str()); + arguments += " "; } m_Makefile->AddUtilityCommand(args[0].c_str(), - result.c_str(), all); + command.c_str(), + arguments.c_str(), all); return true; } diff --git a/Source/cmCustomCommand.cxx b/Source/cmCustomCommand.cxx index f2d19d4..508e069 100644 --- a/Source/cmCustomCommand.cxx +++ b/Source/cmCustomCommand.cxx @@ -45,10 +45,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * The constructor */ cmCustomCommand::cmCustomCommand(const char *src, const char *command, + const char* arguments, std::vector<std::string> dep, std::vector<std::string> out): m_Source(src), m_Command(command), + m_Arguments(arguments), m_Depends(dep), m_Outputs(out) { @@ -61,6 +63,7 @@ cmCustomCommand::cmCustomCommand(const char *src, const char *command, cmCustomCommand::cmCustomCommand(const cmCustomCommand& r): m_Source(r.m_Source), m_Command(r.m_Command), + m_Arguments(r.m_Arguments), m_Depends(r.m_Depends), m_Outputs(r.m_Outputs) { @@ -70,6 +73,7 @@ void cmCustomCommand::ExpandVariables(const cmMakefile &mf) { mf.ExpandVariablesInString(m_Source); mf.ExpandVariablesInString(m_Command); + mf.ExpandVariablesInString(m_Arguments); for (std::vector<std::string>::iterator i = m_Depends.begin(); i != m_Depends.end(); ++i) diff --git a/Source/cmCustomCommand.h b/Source/cmCustomCommand.h index 69e3183..0c9c38d 100644 --- a/Source/cmCustomCommand.h +++ b/Source/cmCustomCommand.h @@ -53,6 +53,7 @@ class cmCustomCommand { public: cmCustomCommand(const char *src, const char *command, + const char* arguments, std::vector<std::string> dep, std::vector<std::string> out); cmCustomCommand(const cmCustomCommand& r); @@ -69,11 +70,17 @@ public: std::string GetSourceName() const {return m_Source;} void SetSourceName(const char *name) {m_Source = name;} - /** - * Return the command to execute - */ + ///! Return the command to execute with arguments + std::string GetCommandAndArguments() const + {return m_Command + " " + m_Arguments;} + + ///! Return the command to execute std::string GetCommand() const {return m_Command;} 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 @@ -90,6 +97,7 @@ public: private: std::string m_Source; std::string m_Command; + std::string m_Arguments; std::vector<std::string> m_Depends; std::vector<std::string> m_Outputs; }; diff --git a/Source/cmDSPWriter.cxx b/Source/cmDSPWriter.cxx index cdd6186..57c9e46 100644 --- a/Source/cmDSPWriter.cxx +++ b/Source/cmDSPWriter.cxx @@ -152,21 +152,22 @@ void cmDSPWriter::AddDSPBuildRule(cmSourceGroup& sourceGroup) std::string dsprule = "${CMAKE_COMMAND} "; m_Makefile->ExpandVariablesInString(dsprule); dsprule = cmSystemTools::HandleNetworkPaths(dsprule.c_str()); - dsprule += makefileIn; - dsprule += " -DSP -H\""; - dsprule += cmSystemTools::HandleNetworkPaths(m_Makefile->GetHomeDirectory()); - dsprule += "\" -S\""; - dsprule += cmSystemTools::HandleNetworkPaths(m_Makefile->GetStartDirectory()); - dsprule += "\" -O\""; - dsprule += cmSystemTools::HandleNetworkPaths(m_Makefile->GetStartOutputDirectory()); - dsprule += "\" -B\""; - dsprule += cmSystemTools::HandleNetworkPaths(m_Makefile->GetHomeOutputDirectory()); - dsprule += "\""; - m_Makefile->ExpandVariablesInString(dsprule); + std::string args = makefileIn; + args += " -DSP -H\""; + args += cmSystemTools::HandleNetworkPaths(m_Makefile->GetHomeDirectory()); + args += "\" -S\""; + args += cmSystemTools::HandleNetworkPaths(m_Makefile->GetStartDirectory()); + args += "\" -O\""; + args += cmSystemTools::HandleNetworkPaths(m_Makefile->GetStartOutputDirectory()); + args += "\" -B\""; + args += cmSystemTools::HandleNetworkPaths(m_Makefile->GetHomeOutputDirectory()); + args += "\""; + m_Makefile->ExpandVariablesInString(args); std::vector<std::string> outputs; outputs.push_back(dspname); cmCustomCommand cc(makefileIn.c_str(), dsprule.c_str(), + args.c_str(), m_Makefile->GetListFiles(), outputs); sourceGroup.AddCustomCommand(cc); @@ -263,9 +264,11 @@ void cmDSPWriter::WriteDSPFile(std::ostream& fout, c != commands.end(); ++c) { totalCommandStr += "\n\t"; - temp= c->first; + temp= c->second.m_Command; cmSystemTools::ConvertToWindowsSlashes(temp); totalCommandStr += temp; + totalCommandStr += " "; + totalCommandStr += c->second.m_Arguments; totalCommand.Merge(c->second); } // Create a dummy file with the name of the source if it does diff --git a/Source/cmDSWWriter.cxx b/Source/cmDSWWriter.cxx index 6a2f678..378a3e2 100644 --- a/Source/cmDSWWriter.cxx +++ b/Source/cmDSWWriter.cxx @@ -102,7 +102,8 @@ void cmDSWWriter::WriteDSWFile(std::ostream& fout) allListFiles.push_back(m_Makefile); // add a special target that depends on ALL projects for easy build // 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); // For each cmMakefile, create a DSP for it, and // add it to this DSW file diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 60af93b..88aaaad 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -470,9 +470,7 @@ void cmMakefile::AddCustomCommand(const char* source, if (m_Targets.find(target) != m_Targets.end()) { std::string c = cmSystemTools::EscapeSpaces(command); - c += " "; - c += commandArgs; - cmCustomCommand cc(source,c.c_str(),depends,outputs); + cmCustomCommand cc(source,c.c_str(),commandArgs,depends,outputs); m_Targets[target].GetCustomCommands().push_back(cc); std::string cacheCommand = command; this->ExpandVariablesInString(cacheCommand); @@ -707,15 +705,17 @@ void cmMakefile::AddExecutable(const char *exeName, void cmMakefile::AddUtilityCommand(const char* utilityName, const char* command, + const char* arguments, bool all) { std::vector<std::string> empty; - this->AddUtilityCommand(utilityName,command,all, + this->AddUtilityCommand(utilityName,command,arguments,all, empty,empty); } void cmMakefile::AddUtilityCommand(const char* utilityName, const char* command, + const char* arguments, bool all, const std::vector<std::string> &dep, const std::vector<std::string> &out) @@ -723,7 +723,7 @@ void cmMakefile::AddUtilityCommand(const char* utilityName, cmTarget target; target.SetType(cmTarget::UTILITY); target.SetInAll(all); - cmCustomCommand cc(utilityName, command, dep, out); + cmCustomCommand cc(utilityName, command, arguments, dep, out); target.GetCustomCommands().push_back(cc); m_Targets.insert(cmTargets::value_type(utilityName,target)); } diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 3b844fa..3b41a71 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -167,9 +167,11 @@ public: */ void AddUtilityCommand(const char* utilityName, const char* command, + const char* arguments, bool all); void AddUtilityCommand(const char* utilityName, const char* command, + const char* arguments, bool all, const std::vector<std::string> &depends, const std::vector<std::string> &outputs); diff --git a/Source/cmSourceGroup.cxx b/Source/cmSourceGroup.cxx index 1ae771c..9f14bb4 100644 --- a/Source/cmSourceGroup.cxx +++ b/Source/cmSourceGroup.cxx @@ -94,32 +94,40 @@ void cmSourceGroup::AddSource(const char* name) */ void cmSourceGroup::AddCustomCommand(const cmCustomCommand &cmd) { + std::string commandAndArgs = cmd.GetCommandAndArguments(); BuildRules::iterator s = m_BuildRules.find(cmd.GetSourceName()); if(s == m_BuildRules.end()) { // The source was not found. Add it with this command. - m_BuildRules[cmd.GetSourceName()][cmd.GetCommand()]. - m_Depends.insert(cmd.GetDepends().begin(),cmd.GetDepends().end()); - m_BuildRules[cmd.GetSourceName()][cmd.GetCommand()]. - m_Outputs.insert(cmd.GetOutputs().begin(),cmd.GetOutputs().end()); + CommandFiles& cmdFiles = m_BuildRules[cmd.GetSourceName()][commandAndArgs]; + cmdFiles.m_Command = cmd.GetCommand(); + cmdFiles.m_Arguments = cmd.GetArguments(); + cmdFiles.m_Depends.insert(cmd.GetDepends().begin(),cmd.GetDepends().end()); + cmdFiles.m_Outputs.insert(cmd.GetOutputs().begin(),cmd.GetOutputs().end()); return; } // The source already exists. See if the command exists. Commands& commands = s->second; - Commands::iterator c = commands.find(cmd.GetCommand()); + Commands::iterator c = commands.find(commandAndArgs); if(c == commands.end()) { // The command did not exist. Add it. - commands[cmd.GetCommand()].m_Depends.insert(cmd.GetDepends().begin(), cmd.GetDepends().end()); - commands[cmd.GetCommand()].m_Outputs.insert(cmd.GetOutputs().begin(), cmd.GetOutputs().end()); + commands[commandAndArgs].m_Command = cmd.GetCommand(); + 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; } // The command already exists for this source. Merge the sets. CommandFiles& commandFiles = c->second; - commandFiles.m_Depends.insert(cmd.GetDepends().begin(), cmd.GetDepends().end()); - commandFiles.m_Outputs.insert(cmd.GetOutputs().begin(), cmd.GetOutputs().end()); + commandFiles.m_Depends.insert(cmd.GetDepends().begin(), + cmd.GetDepends().end()); + commandFiles.m_Outputs.insert(cmd.GetOutputs().begin(), + cmd.GetOutputs().end()); } void cmSourceGroup::Print() const @@ -132,7 +140,9 @@ void cmSourceGroup::Print() const for(Commands::const_iterator j = i->second.begin(); 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 Depends " << j->second.m_Depends.size() << "\n"; } diff --git a/Source/cmSourceGroup.h b/Source/cmSourceGroup.h index d5627ee..e798d44 100644 --- a/Source/cmSourceGroup.h +++ b/Source/cmSourceGroup.h @@ -67,6 +67,8 @@ public: void Merge(const CommandFiles &r); + std::string m_Command; + std::string m_Arguments; std::set<std::string> m_Outputs; std::set<std::string> m_Depends; }; diff --git a/Source/cmVTKWrapJavaCommand.cxx b/Source/cmVTKWrapJavaCommand.cxx index 1deccb1..58a5071 100644 --- a/Source/cmVTKWrapJavaCommand.cxx +++ b/Source/cmVTKWrapJavaCommand.cxx @@ -140,6 +140,7 @@ void cmVTKWrapJavaCommand::FinalPass() m_Makefile->AddUtilityCommand((m_LibraryName+"JavaClasses").c_str(), "", + "", true, alldepends, empty); |