From 0fe42a98572f2339ee763a475ecdd003c8a80ac8 Mon Sep 17 00:00:00 2001 From: Ken Martin Date: Mon, 10 Sep 2001 15:11:15 -0400 Subject: [PATCH] various windows fixes --- Source/cmCableWrapTclCommand.cxx | 41 ++++++++++++++++++------------- Source/cmDSPWriter.cxx | 1 + Source/cmMakefile.cxx | 16 +++++++++--- Source/cmMakefile.h | 4 +-- Source/cmSystemTools.cxx | 13 +++++++--- Source/cmVTKWrapJavaCommand.cxx | 26 +++++++++++++++----- Source/cmVTKWrapPythonCommand.cxx | 13 +++++++--- Source/cmVTKWrapTclCommand.cxx | 17 ++++++++++--- 8 files changed, 94 insertions(+), 37 deletions(-) diff --git a/Source/cmCableWrapTclCommand.cxx b/Source/cmCableWrapTclCommand.cxx index 510d7810b..74253bb05 100644 --- a/Source/cmCableWrapTclCommand.cxx +++ b/Source/cmCableWrapTclCommand.cxx @@ -213,8 +213,11 @@ void cmCableWrapTclCommand::GenerateCableFiles() const m_Makefile->ExpandVariablesInString(command); std::vector depends; depends.push_back(command); - std::string commandArgs = " "+packageConfigName+ - " -tcl "+packageTclFullName+".cxx"; + std::vector commandArgs; + commandArgs.push_back(packageConfigName); + commandArgs.push_back("-tcl"); + std::string tmp = packageTclFullName+".cxx"; + commandArgs.push_back(tmp); depends.push_back(packageConfigName); @@ -223,7 +226,7 @@ void cmCableWrapTclCommand::GenerateCableFiles() const m_Makefile->AddCustomCommand(packageConfigName.c_str(), command.c_str(), - commandArgs.c_str(), + commandArgs, depends, outputs, m_TargetName.c_str()); @@ -341,30 +344,31 @@ void cmCableWrapTclCommand::GenerateCableClassFiles(const char* name, } } - std::string commandArgs = this->GetGccXmlFlagsFromCache(); - commandArgs += " "; - commandArgs += m_Makefile->GetDefineFlags(); - commandArgs += " -I\""; - commandArgs += m_Makefile->GetStartDirectory(); - commandArgs += "\""; + std::vector commandArgs; + commandArgs.push_back(this->GetGccXmlFlagsFromCache()); + commandArgs.push_back(m_Makefile->GetDefineFlags()); + commandArgs.push_back("-I"); + commandArgs.push_back(m_Makefile->GetStartDirectory()); const std::vector& includes = m_Makefile->GetIncludeDirectories(); for(std::vector::const_iterator i = includes.begin(); i != includes.end(); ++i) { - commandArgs += " -I"; - commandArgs += cmSystemTools::EscapeSpaces(i->c_str()); + commandArgs.push_back("-I"); + commandArgs.push_back(cmSystemTools::EscapeSpaces(i->c_str())); } - - commandArgs += " -fxml="+classXmlName+" "+classCxxName; + std::string tmp = "-fxml="; + tmp += classXmlName; + commandArgs.push_back(tmp); + commandArgs.push_back(classCxxName); std::vector outputs; outputs.push_back(classXmlName); m_Makefile->AddCustomCommand(classCxxName.c_str(), command.c_str(), - commandArgs.c_str(), + commandArgs, depends, outputs, m_TargetName.c_str()); } @@ -374,7 +378,11 @@ void cmCableWrapTclCommand::GenerateCableClassFiles(const char* name, std::string command = this->GetCableFromCache(); std::vector depends; depends.push_back(command); - std::string commandArgs = " "+classConfigName+" -tcl "+classTclFullName+".cxx"; + std::vector commandArgs; + commandArgs.push_back(classConfigName); + commandArgs.push_back("-tcl"); + std::string tmp = classTclFullName+".cxx"; + commandArgs.push_back(tmp); depends.push_back(classConfigName); depends.push_back(classXmlName); @@ -384,8 +392,7 @@ void cmCableWrapTclCommand::GenerateCableClassFiles(const char* name, m_Makefile->AddCustomCommand(classConfigName.c_str(), command.c_str(), - commandArgs.c_str(), - depends, + commandArgs, depends, outputs, m_TargetName.c_str()); } diff --git a/Source/cmDSPWriter.cxx b/Source/cmDSPWriter.cxx index 57c9e4616..73da668a2 100644 --- a/Source/cmDSPWriter.cxx +++ b/Source/cmDSPWriter.cxx @@ -266,6 +266,7 @@ void cmDSPWriter::WriteDSPFile(std::ostream& fout, totalCommandStr += "\n\t"; temp= c->second.m_Command; cmSystemTools::ConvertToWindowsSlashes(temp); + temp = cmSystemTools::EscapeSpaces(temp.c_str()); totalCommandStr += temp; totalCommandStr += " "; totalCommandStr += c->second.m_Arguments; diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 88aaaad97..64d3e6901 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -461,7 +461,7 @@ void cmMakefile::RemoveSource(cmSourceFile& cmfile,const char *srclist) void cmMakefile::AddCustomCommand(const char* source, const char* command, - const char* commandArgs, + const std::vector& commandArgs, const std::vector& depends, const std::vector& outputs, const char *target) @@ -470,7 +470,17 @@ void cmMakefile::AddCustomCommand(const char* source, if (m_Targets.find(target) != m_Targets.end()) { std::string c = cmSystemTools::EscapeSpaces(command); - cmCustomCommand cc(source,c.c_str(),commandArgs,depends,outputs); + + std::string combinedArgs; + int i; + + for (i = 0; i < commandArgs.size(); ++i) + { + combinedArgs += cmSystemTools::EscapeSpaces(commandArgs[i].c_str()); + combinedArgs += " "; + } + + cmCustomCommand cc(source,c.c_str(),combinedArgs.c_str(),depends,outputs); m_Targets[target].GetCustomCommands().push_back(cc); std::string cacheCommand = command; this->ExpandVariablesInString(cacheCommand); @@ -484,7 +494,7 @@ void cmMakefile::AddCustomCommand(const char* source, void cmMakefile::AddCustomCommand(const char* source, const char* command, - const char* commandArgs, + const std::vector& commandArgs, const std::vector& depends, const char* output, const char *target) diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 3b41a7140..83c0ab0f1 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -136,14 +136,14 @@ public: */ void AddCustomCommand(const char* source, const char* command, - const char* commandArgs, + const std::vector& commandArgs, const std::vector& depends, const std::vector& outputs, const char *target); void AddCustomCommand(const char* source, const char* command, - const char* commandArgs, + const std::vector& commandArgs, const std::vector& depends, const char* output, const char* target); diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 22898ade8..245b084ec 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -341,9 +341,16 @@ std::string cmSystemTools::EscapeSpaces(const char* str) #if defined(_WIN32) && !defined(__CYGWIN__) std::string result; - result = "\""; - result += cmSystemTools::HandleNetworkPaths(str); - return result+"\""; + // if there are spaces + std::string temp = str; + if (temp.find(" ") != std::string::npos) + { + result = "\""; + result += cmSystemTools::HandleNetworkPaths(str); + return result+"\""; + } + return cmSystemTools::HandleNetworkPaths(str); + #else std::string result = ""; for(const char* ch = str; *ch != '\0'; ++ch) diff --git a/Source/cmVTKWrapJavaCommand.cxx b/Source/cmVTKWrapJavaCommand.cxx index 58a507135..6ef2f30d3 100644 --- a/Source/cmVTKWrapJavaCommand.cxx +++ b/Source/cmVTKWrapJavaCommand.cxx @@ -112,9 +112,13 @@ void cmVTKWrapJavaCommand::FinalPass() std::string hints = "${VTK_WRAP_HINTS}"; std::string resultDirectory = "${VTK_JAVA_HOME}"; + m_Makefile->ExpandVariablesInString(hints); + // wrap all the .h files depends.push_back(wjava); + depends.push_back(hints); depends2.push_back(pjava); + depends2.push_back(hints); for(int classNum = 0; classNum < lastClass; classNum++) { m_Makefile->AddSource(m_WrapClasses[classNum],m_SourceList.c_str()); @@ -124,16 +128,26 @@ void cmVTKWrapJavaCommand::FinalPass() std::string res2 = resultDirectory + "/" + m_OriginalNames[classNum] + ".java"; - std::string cmd = " " + m_WrapHeaders[classNum] + " " - + hints + (m_WrapClasses[classNum].IsAnAbstractClass() ? " 0 " : " 1 ") + " > " + m_WrapClasses[classNum].GetSourceName() + ".cxx"; + std::vector args; + args.push_back(m_WrapHeaders[classNum]); + args.push_back(hints); + args.push_back((m_WrapClasses[classNum].IsAnAbstractClass() ? "0" : "1")); + args.push_back(">"); + args.push_back(res); + m_Makefile->AddCustomCommand(m_WrapHeaders[classNum].c_str(), - wjava.c_str(), cmd.c_str(), depends, + wjava.c_str(), args, depends, res.c_str(), m_LibraryName.c_str()); - cmd = " " + m_WrapHeaders[classNum] + " " - + hints + (m_WrapClasses[classNum].IsAnAbstractClass() ? " 0 " : " 1 ") + " > " + res2; + std::vector args2; + args2.push_back(m_WrapHeaders[classNum]); + args2.push_back(hints); + args2.push_back((m_WrapClasses[classNum].IsAnAbstractClass() ? "0" : "1")); + args2.push_back(">"); + args2.push_back(res2); + m_Makefile->AddCustomCommand(m_WrapHeaders[classNum].c_str(), - pjava.c_str(), cmd.c_str(), depends2, + pjava.c_str(), args2, depends2, res2.c_str(), m_LibraryName.c_str()); alldepends.push_back(res2); } diff --git a/Source/cmVTKWrapPythonCommand.cxx b/Source/cmVTKWrapPythonCommand.cxx index 3f8b7d49c..3dfdb46ad 100644 --- a/Source/cmVTKWrapPythonCommand.cxx +++ b/Source/cmVTKWrapPythonCommand.cxx @@ -106,6 +106,8 @@ void cmVTKWrapPythonCommand::FinalPass() std::vector depends; std::string wpython = "${VTK_WRAP_PYTHON_EXE}"; std::string hints = "${VTK_WRAP_HINTS}"; + + m_Makefile->ExpandVariablesInString(hints); // Create the init file std::string res = m_LibraryName; @@ -123,14 +125,19 @@ void cmVTKWrapPythonCommand::FinalPass() // wrap all the .h files depends.push_back(wpython); + depends.push_back(hints); for(int classNum = 0; classNum < lastClass; classNum++) { m_Makefile->AddSource(m_WrapClasses[classNum],m_SourceList.c_str()); std::string res = m_WrapClasses[classNum].GetSourceName() + ".cxx"; - std::string cmd = m_WrapHeaders[classNum] + " " - + hints + (m_WrapClasses[classNum].IsAnAbstractClass() ? " 0 " : " 1 ") + " > " + m_WrapClasses[classNum].GetSourceName() + ".cxx"; + std::vector args; + args.push_back(m_WrapHeaders[classNum]); + args.push_back(hints); + args.push_back((m_WrapClasses[classNum].IsAnAbstractClass() ? "0" : "1")); + args.push_back(">"); + args.push_back(res); m_Makefile->AddCustomCommand(m_WrapHeaders[classNum].c_str(), - wpython.c_str(), cmd.c_str(), depends, + wpython.c_str(), args, depends, res.c_str(), m_LibraryName.c_str()); } diff --git a/Source/cmVTKWrapTclCommand.cxx b/Source/cmVTKWrapTclCommand.cxx index 2094e254e..a81b049d9 100644 --- a/Source/cmVTKWrapTclCommand.cxx +++ b/Source/cmVTKWrapTclCommand.cxx @@ -139,6 +139,8 @@ void cmVTKWrapTclCommand::FinalPass() std::string wtcl = "${VTK_WRAP_TCL_EXE}"; std::string hints = "${VTK_WRAP_HINTS}"; + m_Makefile->ExpandVariablesInString(hints); + // Create the init file std::string res = m_LibraryName; res += "Init.cxx"; @@ -155,14 +157,23 @@ void cmVTKWrapTclCommand::FinalPass() // wrap all the .h files depends.push_back(wtcl); + depends.push_back(hints); for(int classNum = 0; classNum < lastClass; classNum++) { m_Makefile->AddSource(m_WrapClasses[classNum],m_SourceList.c_str()); std::string res = m_WrapClasses[classNum].GetSourceName() + ".cxx"; - std::string cmd = m_WrapHeaders[classNum] + " " - + hints + (m_WrapClasses[classNum].IsAnAbstractClass() ? " 0 " : " 1 ") + " > " + m_WrapClasses[classNum].GetSourceName() + ".cxx"; + std::vector args; + args.push_back(m_WrapHeaders[classNum]); + args.push_back(hints); + args.push_back((m_WrapClasses[classNum].IsAnAbstractClass() ? "0" : "1")); + args.push_back(">"); + std::string tmp = m_Makefile->GetCurrentOutputDirectory(); + tmp += "/"; + tmp += m_WrapClasses[classNum].GetSourceName() + ".cxx"; + args.push_back(tmp); + m_Makefile->AddCustomCommand(m_WrapHeaders[classNum].c_str(), - wtcl.c_str(), cmd.c_str(), depends, + wtcl.c_str(), args, depends, res.c_str(), m_LibraryName.c_str()); }