[cmake-commits] king committed cmGlobalVisualStudio8Generator.cxx
1.12 1.13 cmLocalGenerator.cxx 1.147 1.148 cmLocalGenerator.h
1.62 1.63 cmLocalUnixMakefileGenerator3.cxx 1.173 1.174
cmLocalVisualStudio6Generator.cxx 1.103 1.104
cmLocalVisualStudio7Generator.cxx 1.145 1.146
cmLocalVisualStudioGenerator.cxx 1.5 1.6
cmLocalVisualStudioGenerator.h 1.2 1.3
cmake-commits at cmake.org
cmake-commits at cmake.org
Thu Sep 21 15:14:09 EDT 2006
Update of /cvsroot/CMake/CMake/Source
In directory public:/mounts/ram/cvs-serv32371/Source
Modified Files:
cmGlobalVisualStudio8Generator.cxx cmLocalGenerator.cxx
cmLocalGenerator.h cmLocalUnixMakefileGenerator3.cxx
cmLocalVisualStudio6Generator.cxx
cmLocalVisualStudio7Generator.cxx
cmLocalVisualStudioGenerator.cxx
cmLocalVisualStudioGenerator.h
Log Message:
BUG: Centralized generation of command line arguments in escaped form. This addresses bug#3786 for several platforms.
Index: cmLocalVisualStudio7Generator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmLocalVisualStudio7Generator.cxx,v
retrieving revision 1.145
retrieving revision 1.146
diff -u -d -r1.145 -r1.146
--- cmLocalVisualStudio7Generator.cxx 26 Aug 2006 14:22:23 -0000 1.145
+++ cmLocalVisualStudio7Generator.cxx 21 Sep 2006 19:14:06 -0000 1.146
@@ -219,12 +219,12 @@
std::string args;
args = "-H";
args += this->Convert(this->Makefile->GetHomeDirectory(),
- START_OUTPUT, SHELL, true);
+ START_OUTPUT, UNCHANGED, true);
commandLine.push_back(args);
args = "-B";
args +=
this->Convert(this->Makefile->GetHomeOutputDirectory(),
- START_OUTPUT, SHELL, true);
+ START_OUTPUT, UNCHANGED, true);
commandLine.push_back(args);
std::string configFile =
Index: cmLocalVisualStudioGenerator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmLocalVisualStudioGenerator.cxx,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- cmLocalVisualStudioGenerator.cxx 8 Aug 2006 15:26:59 -0000 1.5
+++ cmLocalVisualStudioGenerator.cxx 21 Sep 2006 19:14:06 -0000 1.6
@@ -23,6 +23,7 @@
//----------------------------------------------------------------------------
cmLocalVisualStudioGenerator::cmLocalVisualStudioGenerator()
{
+ this->WindowsShell = true;
}
//----------------------------------------------------------------------------
@@ -103,3 +104,53 @@
}
}
}
+
+//----------------------------------------------------------------------------
+std::string
+cmLocalVisualStudioGenerator
+::ConstructScript(const cmCustomCommandLines& commandLines,
+ const char* workingDirectory,
+ const char* newline)
+{
+ // Store the script in a string.
+ std::string script;
+ if(workingDirectory)
+ {
+ script += "cd ";
+ script += this->Convert(workingDirectory, START_OUTPUT, SHELL);
+ script += newline;
+ }
+ // for visual studio IDE add extra stuff to the PATH
+ // if CMAKE_MSVCIDE_RUN_PATH is set.
+ if(this->Makefile->GetDefinition("MSVC_IDE"))
+ {
+ const char* extraPath =
+ this->Makefile->GetDefinition("CMAKE_MSVCIDE_RUN_PATH");
+ if(extraPath)
+ {
+ script += "set PATH=";
+ script += extraPath;
+ script += ";%PATH%";
+ script += newline;
+ }
+ }
+ // Write each command on a single line.
+ for(cmCustomCommandLines::const_iterator cl = commandLines.begin();
+ cl != commandLines.end(); ++cl)
+ {
+ // Start with the command name.
+ const cmCustomCommandLine& commandLine = *cl;
+ script += this->Convert(commandLine[0].c_str(),START_OUTPUT,SHELL);
+
+ // Add the arguments.
+ for(unsigned int j=1;j < commandLine.size(); ++j)
+ {
+ script += " ";
+ script += this->EscapeForShell(commandLine[j].c_str());
+ }
+
+ // End the line.
+ script += newline;
+ }
+ return script;
+}
Index: cmLocalGenerator.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmLocalGenerator.h,v
retrieving revision 1.62
retrieving revision 1.63
diff -u -d -r1.62 -r1.63
--- cmLocalGenerator.h 8 Aug 2006 17:44:25 -0000 1.62
+++ cmLocalGenerator.h 21 Sep 2006 19:14:06 -0000 1.63
@@ -202,10 +202,10 @@
};
protected:
- /** Construct a script from the given list of command lines. */
- std::string ConstructScript(const cmCustomCommandLines& commandLines,
- const char* workingDirectory,
- const char* newline = "\n");
+
+ /** Escape the given string to be used as a command line argument in
+ the native build system shell. */
+ std::string EscapeForShell(const char* str);
/** Construct a comment for a custom command. */
std::string ConstructComment(const cmCustomCommand& cc,
Index: cmLocalGenerator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmLocalGenerator.cxx,v
retrieving revision 1.147
retrieving revision 1.148
diff -u -d -r1.147 -r1.148
--- cmLocalGenerator.cxx 16 Sep 2006 15:52:00 -0000 1.147
+++ cmLocalGenerator.cxx 21 Sep 2006 19:14:06 -0000 1.148
@@ -28,6 +28,8 @@
#include "cmTest.h"
#include "cmake.h"
+#include <cmsys/System.h>
+
#include <ctype.h> // for isalpha
cmLocalGenerator::cmLocalGenerator()
@@ -1898,56 +1900,6 @@
//----------------------------------------------------------------------------
std::string
-cmLocalGenerator::ConstructScript(const cmCustomCommandLines& commandLines,
- const char* workingDirectory,
- const char* newline)
-
-{
- // Store the script in a string.
- std::string script;
- if(workingDirectory)
- {
- script += "cd ";
- script += this->Convert(workingDirectory, START_OUTPUT, SHELL);
- script += newline;
- }
- // for visual studio IDE add extra stuff to the PATH
- // if CMAKE_MSVCIDE_RUN_PATH is set.
- if(this->Makefile->GetDefinition("MSVC_IDE"))
- {
- const char* extraPath =
- this->Makefile->GetDefinition("CMAKE_MSVCIDE_RUN_PATH");
- if(extraPath)
- {
- script += "set PATH=";
- script += extraPath;
- script += ";%PATH%";
- script += newline;
- }
- }
- // Write each command on a single line.
- for(cmCustomCommandLines::const_iterator cl = commandLines.begin();
- cl != commandLines.end(); ++cl)
- {
- // Start with the command name.
- const cmCustomCommandLine& commandLine = *cl;
- script += this->Convert(commandLine[0].c_str(),START_OUTPUT,SHELL);
-
- // Add the arguments.
- for(unsigned int j=1;j < commandLine.size(); ++j)
- {
- script += " ";
- script += cmSystemTools::EscapeSpaces(commandLine[j].c_str());
- }
-
- // End the line.
- script += newline;
- }
- return script;
-}
-
-//----------------------------------------------------------------------------
-std::string
cmLocalGenerator::ConstructComment(const cmCustomCommand& cc,
const char* default_comment)
{
@@ -2289,3 +2241,29 @@
return (this->GlobalGenerator
->GetLanguageFromExtension(source.GetSourceExtension().c_str()));
}
+
+//----------------------------------------------------------------------------
+std::string cmLocalGenerator::EscapeForShell(const char* str)
+{
+ std::string result;
+ if(this->WindowsShell)
+ {
+ int size = cmsysSystem_Windows_ShellArgumentSize(str);
+ std::vector<char> arg(size);
+ cmsysSystem_Windows_ShellArgument(str, &arg[0]);
+ result = &arg[0];
+ }
+ else
+ {
+ for(const char* c = str; *c; ++c)
+ {
+ if(*c == '\\' || *c == '\'' || *c == '"' || *c == ';' ||
+ *c == '(' || *c == ')')
+ {
+ result += "\\";
+ }
+ result += *c;
+ }
+ }
+ return result;
+}
Index: cmGlobalVisualStudio8Generator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmGlobalVisualStudio8Generator.cxx,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- cmGlobalVisualStudio8Generator.cxx 11 May 2006 15:47:03 -0000 1.12
+++ cmGlobalVisualStudio8Generator.cxx 21 Sep 2006 19:14:06 -0000 1.13
@@ -130,12 +130,12 @@
std::string argH = "-H";
argH += lg->Convert(mf->GetHomeDirectory(),
cmLocalGenerator::START_OUTPUT,
- cmLocalGenerator::SHELL, true);
+ cmLocalGenerator::UNCHANGED, true);
commandLine.push_back(argH);
std::string argB = "-B";
argB += lg->Convert(mf->GetHomeOutputDirectory(),
cmLocalGenerator::START_OUTPUT,
- cmLocalGenerator::SHELL, true);
+ cmLocalGenerator::UNCHANGED, true);
commandLine.push_back(argB);
cmCustomCommandLines commandLines;
commandLines.push_back(commandLine);
Index: cmLocalVisualStudio6Generator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmLocalVisualStudio6Generator.cxx,v
retrieving revision 1.103
retrieving revision 1.104
diff -u -d -r1.103 -r1.104
--- cmLocalVisualStudio6Generator.cxx 11 Jul 2006 17:23:02 -0000 1.103
+++ cmLocalVisualStudio6Generator.cxx 21 Sep 2006 19:14:06 -0000 1.104
@@ -223,12 +223,12 @@
std::string args;
args = "-H";
args += this->Convert(this->Makefile->GetHomeDirectory(),
- START_OUTPUT, SHELL, true);
+ START_OUTPUT, UNCHANGED, true);
commandLine.push_back(args);
args = "-B";
args +=
this->Convert(this->Makefile->GetHomeOutputDirectory(),
- START_OUTPUT, SHELL, true);
+ START_OUTPUT, UNCHANGED, true);
commandLine.push_back(args);
std::string configFile =
Index: cmLocalVisualStudioGenerator.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmLocalVisualStudioGenerator.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- cmLocalVisualStudioGenerator.h 1 Aug 2006 14:48:40 -0000 1.2
+++ cmLocalVisualStudioGenerator.h 21 Sep 2006 19:14:06 -0000 1.3
@@ -35,6 +35,12 @@
virtual ~cmLocalVisualStudioGenerator();
protected:
+
+ /** Construct a script from the given list of command lines. */
+ std::string ConstructScript(const cmCustomCommandLines& commandLines,
+ const char* workingDirectory,
+ const char* newline = "\n");
+
// Safe object file name generation.
void ComputeObjectNameRequirements(std::vector<cmSourceGroup> const&);
bool SourceFileCompiles(const cmSourceFile* sf);
Index: cmLocalUnixMakefileGenerator3.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmLocalUnixMakefileGenerator3.cxx,v
retrieving revision 1.173
retrieving revision 1.174
diff -u -d -r1.173 -r1.174
--- cmLocalUnixMakefileGenerator3.cxx 20 Sep 2006 16:13:50 -0000 1.173
+++ cmLocalUnixMakefileGenerator3.cxx 21 Sep 2006 19:14:06 -0000 1.174
@@ -931,16 +931,7 @@
for(unsigned int j=1; j < commandLine.size(); ++j)
{
cmd += " ";
- bool forceOn = cmSystemTools::GetForceUnixPaths();
- if(forceOn && this->WindowsShell)
- {
- cmSystemTools::SetForceUnixPaths(false);
- }
- cmd += cmSystemTools::EscapeSpaces(commandLine[j].c_str());
- if(forceOn && this->WindowsShell)
- {
- cmSystemTools::SetForceUnixPaths(true);
- }
+ cmd += this->EscapeForShell(commandLine[j].c_str());
}
commands1.push_back(cmd);
}
More information about the Cmake-commits
mailing list