diff options
author | Bill Hoffman <bill.hoffman@kitware.com> | 2004-06-23 20:34:38 (GMT) |
---|---|---|
committer | Bill Hoffman <bill.hoffman@kitware.com> | 2004-06-23 20:34:38 (GMT) |
commit | 2705b1bf736e5f98b0862e831fe9ab2799d1d0ee (patch) | |
tree | 4e3cc1d74fbae4c2f34df019f812f00a11b21b2a | |
parent | dc4a6f63b0452968dc564be46909ed228bbc141c (diff) | |
download | CMake-2705b1bf736e5f98b0862e831fe9ab2799d1d0ee.zip CMake-2705b1bf736e5f98b0862e831fe9ab2799d1d0ee.tar.gz CMake-2705b1bf736e5f98b0862e831fe9ab2799d1d0ee.tar.bz2 |
BUG: fix spaces in path on mingw, and change EXEC_PROGRAM to return false when it does not run, also do not convert the directory to an output path for EXEC_PROGRAM as this is done by the process execution, and doing it twice may cause trouble on some shells.
-rw-r--r-- | Source/cmExecProgramCommand.cxx | 11 | ||||
-rw-r--r-- | Source/cmSystemTools.cxx | 15 | ||||
-rw-r--r-- | Source/cmSystemTools.h | 5 | ||||
-rw-r--r-- | Source/cmTryRunCommand.cxx | 2 | ||||
-rw-r--r-- | Source/cmWin32ProcessExecution.cxx | 30 |
5 files changed, 55 insertions, 8 deletions
diff --git a/Source/cmExecProgramCommand.cxx b/Source/cmExecProgramCommand.cxx index b6159ea..66e0cd6 100644 --- a/Source/cmExecProgramCommand.cxx +++ b/Source/cmExecProgramCommand.cxx @@ -88,7 +88,7 @@ bool cmExecProgramCommand::InitialPass(std::vector<std::string> const& args) std::string command; if(arguments.size()) { - command = cmSystemTools::ConvertToOutputPath(args[0].c_str()); + command = cmSystemTools::ConvertToRunCommandPath(args[0].c_str()); command += " "; command += arguments; } @@ -103,15 +103,16 @@ bool cmExecProgramCommand::InitialPass(std::vector<std::string> const& args) } int retVal = 0; std::string output; + bool result = true; if(args.size() - count == 2) { cmSystemTools::MakeDirectory(args[1].c_str()); - cmSystemTools::RunCommand(command.c_str(), output, retVal, - cmSystemTools::ConvertToOutputPath(args[1].c_str()).c_str(), verbose); + result = cmSystemTools::RunCommand(command.c_str(), output, retVal, + args[1].c_str(), verbose); } else { - cmSystemTools::RunCommand(command.c_str(), output, retVal, 0, verbose); + result = cmSystemTools::RunCommand(command.c_str(), output, retVal, 0, verbose); } if ( output_variable.size() > 0 ) @@ -138,6 +139,6 @@ bool cmExecProgramCommand::InitialPass(std::vector<std::string> const& args) m_Makefile->AddDefinition(return_variable.c_str(), buffer); } - return true; + return result; } diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 9fc0060..5c1d5af 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -573,7 +573,6 @@ bool RunCommandViaWin32(const char* command, cmSystemTools::Error("No command specified"); return false; } - cmWin32ProcessExecution resProc; if(cmSystemTools::GetRunCommandHideConsole()) { @@ -586,6 +585,11 @@ bool RunCommandViaWin32(const char* command, } if ( !resProc.StartProcess(command, dir, verbose) ) { + output = resProc.GetOutput(); + if(verbose) + { + cmSystemTools::Stdout(output.c_str()); + } return false; } resProc.Wait(timeout); @@ -1148,6 +1152,15 @@ std::string cmSystemTools::ConvertToOutputPath(const char* path) #endif } +std::string cmSystemTools::ConvertToRunCommandPath(const char* path) +{ +#if defined(_WIN32) && !defined(__CYGWIN__) + return cmSystemTools::ConvertToWindowsOutputPath(path); +#else + return cmSystemTools::ConvertToUnixOutputPath(path); +#endif +} + bool cmSystemTools::StringEndsWith(const char* str1, const char* str2) { if ( !str1 || !str2 || strlen(str1) < strlen(str2) ) diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h index 2862406..f779ecc 100644 --- a/Source/cmSystemTools.h +++ b/Source/cmSystemTools.h @@ -252,7 +252,12 @@ public: { s_ForceUnixPaths = v; } + // ConvertToOutputPath use s_ForceUnixPaths static std::string ConvertToOutputPath(const char* path); + // ConvertToRunCommandPath does not use s_ForceUnixPaths and should + // be used when RunCommand is called from cmake, because the + // running cmake needs paths to be in its format + static std::string ConvertToRunCommandPath(const char* path); //! Check if the first string ends with the second one. static bool StringEndsWith(const char* str1, const char* str2); diff --git a/Source/cmTryRunCommand.cxx b/Source/cmTryRunCommand.cxx index f8c039e..b7300c8 100644 --- a/Source/cmTryRunCommand.cxx +++ b/Source/cmTryRunCommand.cxx @@ -94,7 +94,7 @@ bool cmTryRunCommand::InitialPass(std::vector<std::string> const& argv) if (fullPath.size() > 1) { std::string finalCommand = fullPath; - finalCommand = cmSystemTools::ConvertToOutputPath(fullPath.c_str()); + finalCommand = cmSystemTools::ConvertToRunCommandPath(fullPath.c_str()); if(runArgs.size()) { finalCommand += runArgs; diff --git a/Source/cmWin32ProcessExecution.cxx b/Source/cmWin32ProcessExecution.cxx index ba736db..d06a33c 100644 --- a/Source/cmWin32ProcessExecution.cxx +++ b/Source/cmWin32ProcessExecution.cxx @@ -441,9 +441,37 @@ static BOOL RealPopenCreateProcess(const char *cmdstring, free(s1); return TRUE; } - output += "CreateProcessError "; + + LPVOID lpMsgBuf; + + FormatMessage( + FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, + NULL, + GetLastError(), + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language + (LPTSTR) &lpMsgBuf, + 0, + NULL + ); + + // Free the buffer. + + char* str = 0; + str = strcpy(new char[strlen((char*)lpMsgBuf)+1], (char*)lpMsgBuf); + LocalFree( lpMsgBuf ); + + output += "CreateProcessError: "; + output += str; + output += "\n"; + output += "for command: "; output += s2; + if(path) + { + output += "\nin dir: "; + output += path; + } output += "\n"; + delete [] str; free(s2); free(s1); return FALSE; |