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.
This commit is contained in:
parent
dc4a6f63b0
commit
2705b1bf73
@ -88,7 +88,7 @@ bool cmExecProgramCommand::InitialPass(std::vector<std::string> const& args)
|
|||||||
std::string command;
|
std::string command;
|
||||||
if(arguments.size())
|
if(arguments.size())
|
||||||
{
|
{
|
||||||
command = cmSystemTools::ConvertToOutputPath(args[0].c_str());
|
command = cmSystemTools::ConvertToRunCommandPath(args[0].c_str());
|
||||||
command += " ";
|
command += " ";
|
||||||
command += arguments;
|
command += arguments;
|
||||||
}
|
}
|
||||||
@ -103,15 +103,16 @@ bool cmExecProgramCommand::InitialPass(std::vector<std::string> const& args)
|
|||||||
}
|
}
|
||||||
int retVal = 0;
|
int retVal = 0;
|
||||||
std::string output;
|
std::string output;
|
||||||
|
bool result = true;
|
||||||
if(args.size() - count == 2)
|
if(args.size() - count == 2)
|
||||||
{
|
{
|
||||||
cmSystemTools::MakeDirectory(args[1].c_str());
|
cmSystemTools::MakeDirectory(args[1].c_str());
|
||||||
cmSystemTools::RunCommand(command.c_str(), output, retVal,
|
result = cmSystemTools::RunCommand(command.c_str(), output, retVal,
|
||||||
cmSystemTools::ConvertToOutputPath(args[1].c_str()).c_str(), verbose);
|
args[1].c_str(), verbose);
|
||||||
}
|
}
|
||||||
else
|
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 )
|
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);
|
m_Makefile->AddDefinition(return_variable.c_str(), buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -573,7 +573,6 @@ bool RunCommandViaWin32(const char* command,
|
|||||||
cmSystemTools::Error("No command specified");
|
cmSystemTools::Error("No command specified");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
cmWin32ProcessExecution resProc;
|
cmWin32ProcessExecution resProc;
|
||||||
if(cmSystemTools::GetRunCommandHideConsole())
|
if(cmSystemTools::GetRunCommandHideConsole())
|
||||||
{
|
{
|
||||||
@ -586,6 +585,11 @@ bool RunCommandViaWin32(const char* command,
|
|||||||
}
|
}
|
||||||
if ( !resProc.StartProcess(command, dir, verbose) )
|
if ( !resProc.StartProcess(command, dir, verbose) )
|
||||||
{
|
{
|
||||||
|
output = resProc.GetOutput();
|
||||||
|
if(verbose)
|
||||||
|
{
|
||||||
|
cmSystemTools::Stdout(output.c_str());
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
resProc.Wait(timeout);
|
resProc.Wait(timeout);
|
||||||
@ -1148,6 +1152,15 @@ std::string cmSystemTools::ConvertToOutputPath(const char* path)
|
|||||||
#endif
|
#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)
|
bool cmSystemTools::StringEndsWith(const char* str1, const char* str2)
|
||||||
{
|
{
|
||||||
if ( !str1 || !str2 || strlen(str1) < strlen(str2) )
|
if ( !str1 || !str2 || strlen(str1) < strlen(str2) )
|
||||||
|
@ -252,7 +252,12 @@ public:
|
|||||||
{
|
{
|
||||||
s_ForceUnixPaths = v;
|
s_ForceUnixPaths = v;
|
||||||
}
|
}
|
||||||
|
// ConvertToOutputPath use s_ForceUnixPaths
|
||||||
static std::string ConvertToOutputPath(const char* path);
|
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.
|
//! Check if the first string ends with the second one.
|
||||||
static bool StringEndsWith(const char* str1, const char* str2);
|
static bool StringEndsWith(const char* str1, const char* str2);
|
||||||
|
@ -94,7 +94,7 @@ bool cmTryRunCommand::InitialPass(std::vector<std::string> const& argv)
|
|||||||
if (fullPath.size() > 1)
|
if (fullPath.size() > 1)
|
||||||
{
|
{
|
||||||
std::string finalCommand = fullPath;
|
std::string finalCommand = fullPath;
|
||||||
finalCommand = cmSystemTools::ConvertToOutputPath(fullPath.c_str());
|
finalCommand = cmSystemTools::ConvertToRunCommandPath(fullPath.c_str());
|
||||||
if(runArgs.size())
|
if(runArgs.size())
|
||||||
{
|
{
|
||||||
finalCommand += runArgs;
|
finalCommand += runArgs;
|
||||||
|
@ -441,9 +441,37 @@ static BOOL RealPopenCreateProcess(const char *cmdstring,
|
|||||||
free(s1);
|
free(s1);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
output += "CreateProcessError ";
|
|
||||||
output += s2;
|
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 += "\n";
|
||||||
|
output += "for command: ";
|
||||||
|
output += s2;
|
||||||
|
if(path)
|
||||||
|
{
|
||||||
|
output += "\nin dir: ";
|
||||||
|
output += path;
|
||||||
|
}
|
||||||
|
output += "\n";
|
||||||
|
delete [] str;
|
||||||
free(s2);
|
free(s2);
|
||||||
free(s1);
|
free(s1);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user