cmSystemTools: Teach RunSingleCommand to separate stdout and stderr
Extend the RunSingleCommand signature to capture stdout and stderr separately. Allow both to be captured to the same std::string to preserve existing behavior. Update all call sites to do this so that this refactoring does not introduce functional changes.
This commit is contained in:
parent
f438cd3731
commit
356c26ebdf
@ -92,7 +92,8 @@ int cmCPackIFWGenerator::PackageFiles()
|
|||||||
cmCPackLogger(cmCPackLog::LOG_OUTPUT,
|
cmCPackLogger(cmCPackLog::LOG_OUTPUT,
|
||||||
"- Generate repository" << std::endl);
|
"- Generate repository" << std::endl);
|
||||||
bool res = cmSystemTools::RunSingleCommand(
|
bool res = cmSystemTools::RunSingleCommand(
|
||||||
ifwCmd.c_str(), &output, &retVal, 0, this->GeneratorVerbose, 0);
|
ifwCmd.c_str(), &output, &output,
|
||||||
|
&retVal, 0, this->GeneratorVerbose, 0);
|
||||||
if ( !res || retVal )
|
if ( !res || retVal )
|
||||||
{
|
{
|
||||||
cmGeneratedFileStream ofs(ifwTmpFile.c_str());
|
cmGeneratedFileStream ofs(ifwTmpFile.c_str());
|
||||||
@ -176,7 +177,8 @@ int cmCPackIFWGenerator::PackageFiles()
|
|||||||
int retVal = 1;
|
int retVal = 1;
|
||||||
cmCPackLogger(cmCPackLog::LOG_OUTPUT, "- Generate package" << std::endl);
|
cmCPackLogger(cmCPackLog::LOG_OUTPUT, "- Generate package" << std::endl);
|
||||||
bool res = cmSystemTools::RunSingleCommand(
|
bool res = cmSystemTools::RunSingleCommand(
|
||||||
ifwCmd.c_str(), &output, &retVal, 0, this->GeneratorVerbose, 0);
|
ifwCmd.c_str(), &output, &output,
|
||||||
|
&retVal, 0, this->GeneratorVerbose, 0);
|
||||||
if ( !res || retVal )
|
if ( !res || retVal )
|
||||||
{
|
{
|
||||||
cmGeneratedFileStream ofs(ifwTmpFile.c_str());
|
cmGeneratedFileStream ofs(ifwTmpFile.c_str());
|
||||||
|
@ -64,7 +64,8 @@ bool cmCPackWIXGenerator::RunWiXCommand(std::string const& command)
|
|||||||
std::string output;
|
std::string output;
|
||||||
|
|
||||||
int returnValue = 0;
|
int returnValue = 0;
|
||||||
bool status = cmSystemTools::RunSingleCommand(command.c_str(), &output,
|
bool status = cmSystemTools::RunSingleCommand(
|
||||||
|
command.c_str(), &output, &output,
|
||||||
&returnValue, 0, cmSystemTools::OUTPUT_NONE);
|
&returnValue, 0, cmSystemTools::OUTPUT_NONE);
|
||||||
|
|
||||||
cmsys::ofstream logFile(logFileName.c_str(), std::ios::app);
|
cmsys::ofstream logFile(logFileName.c_str(), std::ios::app);
|
||||||
|
@ -466,7 +466,7 @@ int cmCPackDebGenerator::createDeb()
|
|||||||
|
|
||||||
std::string output;
|
std::string output;
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
int res = cmSystemTools::RunSingleCommand(cmd.c_str(), &output,
|
int res = cmSystemTools::RunSingleCommand(cmd.c_str(), &output, &output,
|
||||||
&retval, this->GetOption("WDIR"), this->GeneratorVerbose, 0);
|
&retval, this->GetOption("WDIR"), this->GeneratorVerbose, 0);
|
||||||
|
|
||||||
if ( !res || retval )
|
if ( !res || retval )
|
||||||
@ -505,7 +505,7 @@ int cmCPackDebGenerator::createDeb()
|
|||||||
cmd += "\"";
|
cmd += "\"";
|
||||||
//std::string output;
|
//std::string output;
|
||||||
//int retVal = -1;
|
//int retVal = -1;
|
||||||
res = cmSystemTools::RunSingleCommand(cmd.c_str(), &output,
|
res = cmSystemTools::RunSingleCommand(cmd.c_str(), &output, &output,
|
||||||
&retval, toplevel.c_str(), this->GeneratorVerbose, 0);
|
&retval, toplevel.c_str(), this->GeneratorVerbose, 0);
|
||||||
if ( !res || retval )
|
if ( !res || retval )
|
||||||
{
|
{
|
||||||
@ -553,7 +553,7 @@ int cmCPackDebGenerator::createDeb()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
res = cmSystemTools::RunSingleCommand(cmd.c_str(), &output,
|
res = cmSystemTools::RunSingleCommand(cmd.c_str(), &output, &output,
|
||||||
&retval, this->GetOption("WDIR"), this->GeneratorVerbose, 0);
|
&retval, this->GetOption("WDIR"), this->GeneratorVerbose, 0);
|
||||||
|
|
||||||
if ( !res || retval )
|
if ( !res || retval )
|
||||||
|
@ -197,7 +197,7 @@ bool cmCPackDragNDropGenerator::RunCommand(std::ostringstream& command,
|
|||||||
|
|
||||||
bool result = cmSystemTools::RunSingleCommand(
|
bool result = cmSystemTools::RunSingleCommand(
|
||||||
command.str().c_str(),
|
command.str().c_str(),
|
||||||
output,
|
output, output,
|
||||||
&exit_code,
|
&exit_code,
|
||||||
0,
|
0,
|
||||||
this->GeneratorVerbose,
|
this->GeneratorVerbose,
|
||||||
|
@ -290,7 +290,8 @@ int cmCPackGenerator::InstallProjectViaInstallCommands(
|
|||||||
<< std::endl);
|
<< std::endl);
|
||||||
std::string output;
|
std::string output;
|
||||||
int retVal = 1;
|
int retVal = 1;
|
||||||
bool resB = cmSystemTools::RunSingleCommand(it->c_str(), &output,
|
bool resB = cmSystemTools::RunSingleCommand(
|
||||||
|
it->c_str(), &output, &output,
|
||||||
&retVal, 0, this->GeneratorVerbose, 0);
|
&retVal, 0, this->GeneratorVerbose, 0);
|
||||||
if ( !resB || retVal )
|
if ( !resB || retVal )
|
||||||
{
|
{
|
||||||
@ -668,7 +669,7 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects(
|
|||||||
int retVal = 1;
|
int retVal = 1;
|
||||||
bool resB =
|
bool resB =
|
||||||
cmSystemTools::RunSingleCommand(buildCommand.c_str(),
|
cmSystemTools::RunSingleCommand(buildCommand.c_str(),
|
||||||
&output,
|
&output, &output,
|
||||||
&retVal,
|
&retVal,
|
||||||
installDirectory.c_str(),
|
installDirectory.c_str(),
|
||||||
this->GeneratorVerbose, 0);
|
this->GeneratorVerbose, 0);
|
||||||
|
@ -324,7 +324,7 @@ int cmCPackNSISGenerator::PackageFiles()
|
|||||||
<< std::endl);
|
<< std::endl);
|
||||||
std::string output;
|
std::string output;
|
||||||
int retVal = 1;
|
int retVal = 1;
|
||||||
bool res = cmSystemTools::RunSingleCommand(nsisCmd.c_str(), &output,
|
bool res = cmSystemTools::RunSingleCommand(nsisCmd.c_str(), &output, &output,
|
||||||
&retVal, 0, this->GeneratorVerbose, 0);
|
&retVal, 0, this->GeneratorVerbose, 0);
|
||||||
if ( !res || retVal )
|
if ( !res || retVal )
|
||||||
{
|
{
|
||||||
@ -430,8 +430,8 @@ int cmCPackNSISGenerator::InitializeInternal()
|
|||||||
<< nsisCmd << std::endl);
|
<< nsisCmd << std::endl);
|
||||||
std::string output;
|
std::string output;
|
||||||
int retVal = 1;
|
int retVal = 1;
|
||||||
bool resS = cmSystemTools::RunSingleCommand(nsisCmd.c_str(),
|
bool resS = cmSystemTools::RunSingleCommand(
|
||||||
&output, &retVal, 0, this->GeneratorVerbose, 0);
|
nsisCmd.c_str(), &output, &output, &retVal, 0, this->GeneratorVerbose, 0);
|
||||||
cmsys::RegularExpression versionRex("v([0-9]+.[0-9]+)");
|
cmsys::RegularExpression versionRex("v([0-9]+.[0-9]+)");
|
||||||
cmsys::RegularExpression versionRexCVS("v(.*)\\.cvs");
|
cmsys::RegularExpression versionRexCVS("v(.*)\\.cvs");
|
||||||
if ( !resS || retVal ||
|
if ( !resS || retVal ||
|
||||||
@ -836,9 +836,9 @@ CreateComponentDescription(cmCPackComponent *component,
|
|||||||
zipListFileName.c_str());
|
zipListFileName.c_str());
|
||||||
std::string output;
|
std::string output;
|
||||||
int retVal = -1;
|
int retVal = -1;
|
||||||
int res = cmSystemTools::RunSingleCommand(cmd.c_str(), &output, &retVal,
|
int res = cmSystemTools::RunSingleCommand(
|
||||||
dirName.c_str(),
|
cmd.c_str(), &output, &output,
|
||||||
cmSystemTools::OUTPUT_NONE, 0);
|
&retVal, dirName.c_str(), cmSystemTools::OUTPUT_NONE, 0);
|
||||||
if ( !res || retVal )
|
if ( !res || retVal )
|
||||||
{
|
{
|
||||||
std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
|
std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
|
||||||
|
@ -180,9 +180,9 @@ int cmCPackOSXX11Generator::PackageFiles()
|
|||||||
bool res = false;
|
bool res = false;
|
||||||
while(numTries > 0)
|
while(numTries > 0)
|
||||||
{
|
{
|
||||||
res = cmSystemTools::RunSingleCommand(dmgCmd.str().c_str(), &output,
|
res = cmSystemTools::RunSingleCommand(
|
||||||
&retVal, 0,
|
dmgCmd.str().c_str(), &output, &output,
|
||||||
this->GeneratorVerbose, 0);
|
&retVal, 0, this->GeneratorVerbose, 0);
|
||||||
if ( res && !retVal )
|
if ( res && !retVal )
|
||||||
{
|
{
|
||||||
numTries = -1;
|
numTries = -1;
|
||||||
|
@ -378,9 +378,9 @@ int cmCPackPackageMakerGenerator::PackageFiles()
|
|||||||
bool res = false;
|
bool res = false;
|
||||||
while(numTries > 0)
|
while(numTries > 0)
|
||||||
{
|
{
|
||||||
res = cmSystemTools::RunSingleCommand(dmgCmd.str().c_str(), &output,
|
res = cmSystemTools::RunSingleCommand(
|
||||||
&retVal, 0, this->GeneratorVerbose,
|
dmgCmd.str().c_str(), &output, &output,
|
||||||
0);
|
&retVal, 0, this->GeneratorVerbose, 0);
|
||||||
if ( res && !retVal )
|
if ( res && !retVal )
|
||||||
{
|
{
|
||||||
numTries = -1;
|
numTries = -1;
|
||||||
@ -657,8 +657,9 @@ bool cmCPackPackageMakerGenerator::RunPackageMaker(const char *command,
|
|||||||
cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Execute: " << command << std::endl);
|
cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Execute: " << command << std::endl);
|
||||||
std::string output;
|
std::string output;
|
||||||
int retVal = 1;
|
int retVal = 1;
|
||||||
bool res = cmSystemTools::RunSingleCommand(command, &output, &retVal, 0,
|
bool res = cmSystemTools::RunSingleCommand(
|
||||||
this->GeneratorVerbose, 0);
|
command, &output, &output,
|
||||||
|
&retVal, 0, this->GeneratorVerbose, 0);
|
||||||
cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Done running package maker"
|
cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Done running package maker"
|
||||||
<< std::endl);
|
<< std::endl);
|
||||||
if ( !res || retVal )
|
if ( !res || retVal )
|
||||||
|
@ -709,7 +709,8 @@ int cmCTestScriptHandler::CheckOutSourceDir()
|
|||||||
output = "";
|
output = "";
|
||||||
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
|
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
|
||||||
"Run cvs: " << this->CVSCheckOut << std::endl);
|
"Run cvs: " << this->CVSCheckOut << std::endl);
|
||||||
res = cmSystemTools::RunSingleCommand(this->CVSCheckOut.c_str(), &output,
|
res = cmSystemTools::RunSingleCommand(
|
||||||
|
this->CVSCheckOut.c_str(), &output, &output,
|
||||||
&retVal, this->CTestRoot.c_str(), this->HandlerVerbose,
|
&retVal, this->CTestRoot.c_str(), this->HandlerVerbose,
|
||||||
0 /*this->TimeOut*/);
|
0 /*this->TimeOut*/);
|
||||||
if (!res || retVal != 0)
|
if (!res || retVal != 0)
|
||||||
@ -789,7 +790,8 @@ int cmCTestScriptHandler::PerformExtraUpdates()
|
|||||||
retVal = 0;
|
retVal = 0;
|
||||||
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Run Update: "
|
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Run Update: "
|
||||||
<< fullCommand << std::endl);
|
<< fullCommand << std::endl);
|
||||||
res = cmSystemTools::RunSingleCommand(fullCommand.c_str(), &output,
|
res = cmSystemTools::RunSingleCommand(
|
||||||
|
fullCommand.c_str(), &output, &output,
|
||||||
&retVal, cvsArgs[0].c_str(),
|
&retVal, cvsArgs[0].c_str(),
|
||||||
this->HandlerVerbose, 0 /*this->TimeOut*/);
|
this->HandlerVerbose, 0 /*this->TimeOut*/);
|
||||||
if (!res || retVal != 0)
|
if (!res || retVal != 0)
|
||||||
@ -910,7 +912,8 @@ int cmCTestScriptHandler::RunConfigurationDashboard()
|
|||||||
retVal = 0;
|
retVal = 0;
|
||||||
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Run cmake command: "
|
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Run cmake command: "
|
||||||
<< command << std::endl);
|
<< command << std::endl);
|
||||||
res = cmSystemTools::RunSingleCommand(command.c_str(), &output,
|
res = cmSystemTools::RunSingleCommand(
|
||||||
|
command.c_str(), &output, &output,
|
||||||
&retVal, this->BinaryDir.c_str(),
|
&retVal, this->BinaryDir.c_str(),
|
||||||
this->HandlerVerbose, 0 /*this->TimeOut*/);
|
this->HandlerVerbose, 0 /*this->TimeOut*/);
|
||||||
|
|
||||||
@ -956,7 +959,8 @@ int cmCTestScriptHandler::RunConfigurationDashboard()
|
|||||||
retVal = 0;
|
retVal = 0;
|
||||||
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Run ctest command: "
|
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Run ctest command: "
|
||||||
<< command << std::endl);
|
<< command << std::endl);
|
||||||
res = cmSystemTools::RunSingleCommand(command.c_str(), &output,
|
res = cmSystemTools::RunSingleCommand(
|
||||||
|
command.c_str(), &output, &output,
|
||||||
&retVal, this->BinaryDir.c_str(), this->HandlerVerbose,
|
&retVal, this->BinaryDir.c_str(), this->HandlerVerbose,
|
||||||
0 /*this->TimeOut*/);
|
0 /*this->TimeOut*/);
|
||||||
|
|
||||||
|
@ -1334,7 +1334,7 @@ int cmCTestTestHandler::ExecuteCommands(std::vector<std::string>& vec)
|
|||||||
int retVal = 0;
|
int retVal = 0;
|
||||||
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Run command: " <<
|
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Run command: " <<
|
||||||
*it << std::endl, this->Quiet);
|
*it << std::endl, this->Quiet);
|
||||||
if ( !cmSystemTools::RunSingleCommand(it->c_str(), 0, &retVal, 0,
|
if ( !cmSystemTools::RunSingleCommand(it->c_str(), 0, 0, &retVal, 0,
|
||||||
cmSystemTools::OUTPUT_MERGE
|
cmSystemTools::OUTPUT_MERGE
|
||||||
/*this->Verbose*/) || retVal != 0 )
|
/*this->Verbose*/) || retVal != 0 )
|
||||||
{
|
{
|
||||||
|
@ -49,7 +49,7 @@ bool cmBuildNameCommand
|
|||||||
if(this->Makefile->GetDefinition("UNIX"))
|
if(this->Makefile->GetDefinition("UNIX"))
|
||||||
{
|
{
|
||||||
buildname = "";
|
buildname = "";
|
||||||
cmSystemTools::RunSingleCommand("uname -a", &buildname);
|
cmSystemTools::RunSingleCommand("uname -a", &buildname, &buildname);
|
||||||
if(!buildname.empty())
|
if(!buildname.empty())
|
||||||
{
|
{
|
||||||
std::string RegExp = "([^ ]*) [^ ]* ([^ ]*) ";
|
std::string RegExp = "([^ ]*) [^ ]* ([^ ]*) ";
|
||||||
|
@ -1163,7 +1163,7 @@ cmExtraEclipseCDT4Generator::GetEclipsePath(const std::string& path)
|
|||||||
#if defined(__CYGWIN__)
|
#if defined(__CYGWIN__)
|
||||||
std::string cmd = "cygpath -m " + path;
|
std::string cmd = "cygpath -m " + path;
|
||||||
std::string out;
|
std::string out;
|
||||||
if (!cmSystemTools::RunSingleCommand(cmd.c_str(), &out))
|
if (!cmSystemTools::RunSingleCommand(cmd.c_str(), &out, &out))
|
||||||
{
|
{
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
@ -1737,7 +1737,7 @@ int cmGlobalGenerator::Build(
|
|||||||
output += cmSystemTools::PrintSingleCommand(cleanCommand);
|
output += cmSystemTools::PrintSingleCommand(cleanCommand);
|
||||||
output += "\n";
|
output += "\n";
|
||||||
|
|
||||||
if (!cmSystemTools::RunSingleCommand(cleanCommand, outputPtr,
|
if (!cmSystemTools::RunSingleCommand(cleanCommand, outputPtr, outputPtr,
|
||||||
&retVal, 0, outputflag, timeout))
|
&retVal, 0, outputflag, timeout))
|
||||||
{
|
{
|
||||||
cmSystemTools::SetRunCommandHideConsole(hideconsole);
|
cmSystemTools::SetRunCommandHideConsole(hideconsole);
|
||||||
@ -1758,7 +1758,7 @@ int cmGlobalGenerator::Build(
|
|||||||
output += makeCommandStr;
|
output += makeCommandStr;
|
||||||
output += "\n";
|
output += "\n";
|
||||||
|
|
||||||
if (!cmSystemTools::RunSingleCommand(makeCommand, outputPtr,
|
if (!cmSystemTools::RunSingleCommand(makeCommand, outputPtr, outputPtr,
|
||||||
&retVal, 0, outputflag, timeout))
|
&retVal, 0, outputflag, timeout))
|
||||||
{
|
{
|
||||||
cmSystemTools::SetRunCommandHideConsole(hideconsole);
|
cmSystemTools::SetRunCommandHideConsole(hideconsole);
|
||||||
|
@ -1233,7 +1233,7 @@ std::string cmGlobalNinjaGenerator::ninjaVersion() const
|
|||||||
std::string version;
|
std::string version;
|
||||||
std::string command = ninjaCmd() + " --version";
|
std::string command = ninjaCmd() + " --version";
|
||||||
cmSystemTools::RunSingleCommand(command.c_str(),
|
cmSystemTools::RunSingleCommand(command.c_str(),
|
||||||
&version, 0, 0,
|
&version, 0, 0, 0,
|
||||||
cmSystemTools::OUTPUT_NONE);
|
cmSystemTools::OUTPUT_NONE);
|
||||||
|
|
||||||
return version;
|
return version;
|
||||||
|
@ -164,8 +164,8 @@ cmGlobalGenerator* cmGlobalXCodeGenerator::Factory
|
|||||||
{
|
{
|
||||||
std::string out;
|
std::string out;
|
||||||
std::string::size_type pos;
|
std::string::size_type pos;
|
||||||
if(cmSystemTools::RunSingleCommand("xcode-select --print-path", &out, 0, 0,
|
if(cmSystemTools::RunSingleCommand("xcode-select --print-path", &out, 0,
|
||||||
cmSystemTools::OUTPUT_NONE) &&
|
0, 0, cmSystemTools::OUTPUT_NONE) &&
|
||||||
(pos = out.find(".app/"), pos != out.npos))
|
(pos = out.find(".app/"), pos != out.npos))
|
||||||
{
|
{
|
||||||
versionFile = out.substr(0, pos+5)+"Contents/version.plist";
|
versionFile = out.substr(0, pos+5)+"Contents/version.plist";
|
||||||
|
@ -188,7 +188,7 @@ std::string cmQtAutoGenerators::ListQt5RccInputs(cmSourceFile* sf,
|
|||||||
|
|
||||||
std::string output;
|
std::string output;
|
||||||
int retVal = 0;
|
int retVal = 0;
|
||||||
bool result = cmSystemTools::RunSingleCommand(command, &output,
|
bool result = cmSystemTools::RunSingleCommand(command, &output, &output,
|
||||||
&retVal, 0,
|
&retVal, 0,
|
||||||
cmSystemTools::OUTPUT_NONE);
|
cmSystemTools::OUTPUT_NONE);
|
||||||
if (!result || retVal)
|
if (!result || retVal)
|
||||||
@ -2196,7 +2196,8 @@ bool cmQtAutoGenerators::GenerateMoc(const std::string& sourceFile,
|
|||||||
|
|
||||||
std::string output;
|
std::string output;
|
||||||
int retVal = 0;
|
int retVal = 0;
|
||||||
bool result = cmSystemTools::RunSingleCommand(command, &output, &retVal);
|
bool result = cmSystemTools::RunSingleCommand(command, &output, &output,
|
||||||
|
&retVal);
|
||||||
if (!result || retVal)
|
if (!result || retVal)
|
||||||
{
|
{
|
||||||
std::cerr << "AUTOGEN: error: process for " << mocFilePath <<" failed:\n"
|
std::cerr << "AUTOGEN: error: process for " << mocFilePath <<" failed:\n"
|
||||||
@ -2265,7 +2266,8 @@ bool cmQtAutoGenerators::GenerateUi(const std::string& realName,
|
|||||||
}
|
}
|
||||||
std::string output;
|
std::string output;
|
||||||
int retVal = 0;
|
int retVal = 0;
|
||||||
bool result = cmSystemTools::RunSingleCommand(command, &output, &retVal);
|
bool result = cmSystemTools::RunSingleCommand(command, &output, &output,
|
||||||
|
&retVal);
|
||||||
if (!result || retVal)
|
if (!result || retVal)
|
||||||
{
|
{
|
||||||
std::cerr << "AUTOUIC: error: process for " << ui_output_file <<
|
std::cerr << "AUTOUIC: error: process for " << ui_output_file <<
|
||||||
@ -2355,7 +2357,8 @@ bool cmQtAutoGenerators::GenerateQrc()
|
|||||||
}
|
}
|
||||||
std::string output;
|
std::string output;
|
||||||
int retVal = 0;
|
int retVal = 0;
|
||||||
bool result = cmSystemTools::RunSingleCommand(command, &output, &retVal);
|
bool result = cmSystemTools::RunSingleCommand(command, &output, &output,
|
||||||
|
&retVal);
|
||||||
if (!result || retVal)
|
if (!result || retVal)
|
||||||
{
|
{
|
||||||
std::cerr << "AUTORCC: error: process for " << rcc_output_file <<
|
std::cerr << "AUTORCC: error: process for " << rcc_output_file <<
|
||||||
|
@ -63,7 +63,7 @@ bool cmSiteNameCommand
|
|||||||
{
|
{
|
||||||
std::string host;
|
std::string host;
|
||||||
cmSystemTools::RunSingleCommand(hostname_cmd.c_str(),
|
cmSystemTools::RunSingleCommand(hostname_cmd.c_str(),
|
||||||
&host, 0, 0, cmSystemTools::OUTPUT_NONE);
|
&host, 0, 0, 0, cmSystemTools::OUTPUT_NONE);
|
||||||
|
|
||||||
// got the hostname
|
// got the hostname
|
||||||
if (!host.empty())
|
if (!host.empty())
|
||||||
|
@ -659,7 +659,8 @@ std::vector<std::string> cmSystemTools::ParseArguments(const char* command)
|
|||||||
|
|
||||||
|
|
||||||
bool cmSystemTools::RunSingleCommand(std::vector<std::string>const& command,
|
bool cmSystemTools::RunSingleCommand(std::vector<std::string>const& command,
|
||||||
std::string* output ,
|
std::string* captureStdOut,
|
||||||
|
std::string* captureStdErr,
|
||||||
int* retVal , const char* dir ,
|
int* retVal , const char* dir ,
|
||||||
OutputOption outputflag ,
|
OutputOption outputflag ,
|
||||||
double timeout )
|
double timeout )
|
||||||
@ -671,9 +672,13 @@ bool cmSystemTools::RunSingleCommand(std::vector<std::string>const& command,
|
|||||||
argv.push_back(a->c_str());
|
argv.push_back(a->c_str());
|
||||||
}
|
}
|
||||||
argv.push_back(0);
|
argv.push_back(0);
|
||||||
if ( output )
|
if ( captureStdOut )
|
||||||
{
|
{
|
||||||
*output = "";
|
*captureStdOut = "";
|
||||||
|
}
|
||||||
|
if (captureStdErr && captureStdErr != captureStdOut)
|
||||||
|
{
|
||||||
|
*captureStdErr = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
cmsysProcess* cp = cmsysProcess_New();
|
cmsysProcess* cp = cmsysProcess_New();
|
||||||
@ -693,15 +698,17 @@ bool cmSystemTools::RunSingleCommand(std::vector<std::string>const& command,
|
|||||||
cmsysProcess_SetTimeout(cp, timeout);
|
cmsysProcess_SetTimeout(cp, timeout);
|
||||||
cmsysProcess_Execute(cp);
|
cmsysProcess_Execute(cp);
|
||||||
|
|
||||||
std::vector<char> tempOutput;
|
std::vector<char> tempStdOut;
|
||||||
|
std::vector<char> tempStdErr;
|
||||||
char* data;
|
char* data;
|
||||||
int length;
|
int length;
|
||||||
int pipe;
|
int pipe;
|
||||||
if(outputflag != OUTPUT_PASSTHROUGH && (output || outputflag != OUTPUT_NONE))
|
if(outputflag != OUTPUT_PASSTHROUGH &&
|
||||||
|
(captureStdOut || captureStdErr || outputflag != OUTPUT_NONE))
|
||||||
{
|
{
|
||||||
while((pipe = cmsysProcess_WaitForData(cp, &data, &length, 0)) > 0)
|
while((pipe = cmsysProcess_WaitForData(cp, &data, &length, 0)) > 0)
|
||||||
{
|
{
|
||||||
if(output || outputflag != OUTPUT_NONE)
|
if(captureStdOut || captureStdErr || outputflag != OUTPUT_NONE)
|
||||||
{
|
{
|
||||||
// Translate NULL characters in the output into valid text.
|
// Translate NULL characters in the output into valid text.
|
||||||
// Visual Studio 7 puts these characters in the output of its
|
// Visual Studio 7 puts these characters in the output of its
|
||||||
@ -714,9 +721,21 @@ bool cmSystemTools::RunSingleCommand(std::vector<std::string>const& command,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( output )
|
if(pipe == cmsysProcess_Pipe_STDOUT ||
|
||||||
|
(pipe == cmsysProcess_Pipe_STDERR &&
|
||||||
|
captureStdOut == captureStdErr))
|
||||||
{
|
{
|
||||||
tempOutput.insert(tempOutput.end(), data, data+length);
|
if (captureStdOut)
|
||||||
|
{
|
||||||
|
tempStdOut.insert(tempStdOut.end(), data, data+length);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(pipe == cmsysProcess_Pipe_STDERR)
|
||||||
|
{
|
||||||
|
if (captureStdErr)
|
||||||
|
{
|
||||||
|
tempStdErr.insert(tempStdErr.end(), data, data+length);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(outputflag != OUTPUT_NONE)
|
if(outputflag != OUTPUT_NONE)
|
||||||
{
|
{
|
||||||
@ -740,9 +759,14 @@ bool cmSystemTools::RunSingleCommand(std::vector<std::string>const& command,
|
|||||||
}
|
}
|
||||||
|
|
||||||
cmsysProcess_WaitForExit(cp, 0);
|
cmsysProcess_WaitForExit(cp, 0);
|
||||||
if ( output && tempOutput.begin() != tempOutput.end())
|
if ( captureStdOut && tempStdOut.begin() != tempStdOut.end())
|
||||||
{
|
{
|
||||||
output->append(&*tempOutput.begin(), tempOutput.size());
|
captureStdOut->append(&*tempStdOut.begin(), tempStdOut.size());
|
||||||
|
}
|
||||||
|
if ( captureStdErr && captureStdErr != captureStdOut &&
|
||||||
|
tempStdErr.begin() != tempStdErr.end())
|
||||||
|
{
|
||||||
|
captureStdErr->append(&*tempStdErr.begin(), tempStdErr.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool result = true;
|
bool result = true;
|
||||||
@ -767,9 +791,9 @@ bool cmSystemTools::RunSingleCommand(std::vector<std::string>const& command,
|
|||||||
{
|
{
|
||||||
std::cerr << exception_str << std::endl;
|
std::cerr << exception_str << std::endl;
|
||||||
}
|
}
|
||||||
if ( output )
|
if ( captureStdErr )
|
||||||
{
|
{
|
||||||
output->append(exception_str, strlen(exception_str));
|
captureStdErr->append(exception_str, strlen(exception_str));
|
||||||
}
|
}
|
||||||
result = false;
|
result = false;
|
||||||
}
|
}
|
||||||
@ -780,9 +804,9 @@ bool cmSystemTools::RunSingleCommand(std::vector<std::string>const& command,
|
|||||||
{
|
{
|
||||||
std::cerr << error_str << std::endl;
|
std::cerr << error_str << std::endl;
|
||||||
}
|
}
|
||||||
if ( output )
|
if ( captureStdErr )
|
||||||
{
|
{
|
||||||
output->append(error_str, strlen(error_str));
|
captureStdErr->append(error_str, strlen(error_str));
|
||||||
}
|
}
|
||||||
result = false;
|
result = false;
|
||||||
}
|
}
|
||||||
@ -793,9 +817,9 @@ bool cmSystemTools::RunSingleCommand(std::vector<std::string>const& command,
|
|||||||
{
|
{
|
||||||
std::cerr << error_str << std::endl;
|
std::cerr << error_str << std::endl;
|
||||||
}
|
}
|
||||||
if ( output )
|
if ( captureStdErr )
|
||||||
{
|
{
|
||||||
output->append(error_str, strlen(error_str));
|
captureStdErr->append(error_str, strlen(error_str));
|
||||||
}
|
}
|
||||||
result = false;
|
result = false;
|
||||||
}
|
}
|
||||||
@ -806,7 +830,8 @@ bool cmSystemTools::RunSingleCommand(std::vector<std::string>const& command,
|
|||||||
|
|
||||||
bool cmSystemTools::RunSingleCommand(
|
bool cmSystemTools::RunSingleCommand(
|
||||||
const char* command,
|
const char* command,
|
||||||
std::string* output,
|
std::string* captureStdOut,
|
||||||
|
std::string* captureStdErr,
|
||||||
int *retVal,
|
int *retVal,
|
||||||
const char* dir,
|
const char* dir,
|
||||||
OutputOption outputflag,
|
OutputOption outputflag,
|
||||||
@ -823,8 +848,8 @@ bool cmSystemTools::RunSingleCommand(
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return cmSystemTools::RunSingleCommand(args, output,retVal,
|
return cmSystemTools::RunSingleCommand(args, captureStdOut, captureStdErr,
|
||||||
dir, outputflag, timeout);
|
retVal, dir, outputflag, timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string
|
std::string
|
||||||
|
@ -223,7 +223,9 @@ public:
|
|||||||
OUTPUT_NORMAL,
|
OUTPUT_NORMAL,
|
||||||
OUTPUT_PASSTHROUGH
|
OUTPUT_PASSTHROUGH
|
||||||
};
|
};
|
||||||
static bool RunSingleCommand(const char* command, std::string* output = 0,
|
static bool RunSingleCommand(const char* command,
|
||||||
|
std::string* captureStdOut = 0,
|
||||||
|
std::string* captureStdErr = 0,
|
||||||
int* retVal = 0, const char* dir = 0,
|
int* retVal = 0, const char* dir = 0,
|
||||||
OutputOption outputflag = OUTPUT_MERGE,
|
OutputOption outputflag = OUTPUT_MERGE,
|
||||||
double timeout = 0.0);
|
double timeout = 0.0);
|
||||||
@ -233,7 +235,8 @@ public:
|
|||||||
* be in comand[1]...command[command.size()]
|
* be in comand[1]...command[command.size()]
|
||||||
*/
|
*/
|
||||||
static bool RunSingleCommand(std::vector<std::string> const& command,
|
static bool RunSingleCommand(std::vector<std::string> const& command,
|
||||||
std::string* output = 0,
|
std::string* captureStdOut = 0,
|
||||||
|
std::string* captureStdErr = 0,
|
||||||
int* retVal = 0, const char* dir = 0,
|
int* retVal = 0, const char* dir = 0,
|
||||||
OutputOption outputflag = OUTPUT_MERGE,
|
OutputOption outputflag = OUTPUT_MERGE,
|
||||||
double timeout = 0.0);
|
double timeout = 0.0);
|
||||||
|
@ -224,7 +224,7 @@ void cmTryRunCommand::RunExecutable(const std::string& runArgs,
|
|||||||
}
|
}
|
||||||
int timeout = 0;
|
int timeout = 0;
|
||||||
bool worked = cmSystemTools::RunSingleCommand(finalCommand.c_str(),
|
bool worked = cmSystemTools::RunSingleCommand(finalCommand.c_str(),
|
||||||
out, &retVal,
|
out, out, &retVal,
|
||||||
0, cmSystemTools::OUTPUT_NONE, timeout);
|
0, cmSystemTools::OUTPUT_NONE, timeout);
|
||||||
// set the run var
|
// set the run var
|
||||||
char retChar[1000];
|
char retChar[1000];
|
||||||
|
@ -206,8 +206,9 @@ static int process( const std::string& srcfilename,
|
|||||||
}
|
}
|
||||||
// run the command
|
// run the command
|
||||||
int exit_code = 0;
|
int exit_code = 0;
|
||||||
bool run = cmSystemTools::RunSingleCommand(command, &output, &exit_code,
|
bool run = cmSystemTools::RunSingleCommand(command, &output, &output,
|
||||||
dir.c_str(), cmSystemTools::OUTPUT_NONE);
|
&exit_code, dir.c_str(),
|
||||||
|
cmSystemTools::OUTPUT_NONE);
|
||||||
|
|
||||||
// process the include directives and output everything else
|
// process the include directives and output everything else
|
||||||
std::stringstream ss(output);
|
std::stringstream ss(output);
|
||||||
|
@ -267,7 +267,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
|
|||||||
std::vector<std::string> cmd(ai, ae);
|
std::vector<std::string> cmd(ai, ae);
|
||||||
int retval;
|
int retval;
|
||||||
if(cmSystemTools::RunSingleCommand(
|
if(cmSystemTools::RunSingleCommand(
|
||||||
cmd, 0, &retval, NULL, cmSystemTools::OUTPUT_PASSTHROUGH))
|
cmd, 0, 0, &retval, NULL, cmSystemTools::OUTPUT_PASSTHROUGH))
|
||||||
{
|
{
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
@ -398,7 +398,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
|
|||||||
time(&time_start);
|
time(&time_start);
|
||||||
clock_start = clock();
|
clock_start = clock();
|
||||||
int ret =0;
|
int ret =0;
|
||||||
cmSystemTools::RunSingleCommand(command.c_str(), 0, &ret);
|
cmSystemTools::RunSingleCommand(command.c_str(), 0, 0, &ret);
|
||||||
|
|
||||||
clock_finish = clock();
|
clock_finish = clock();
|
||||||
time(&time_finish);
|
time(&time_finish);
|
||||||
@ -454,7 +454,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
|
|||||||
std::string command = cmWrap('"', cmRange(args).advance(3), '"', " ");
|
std::string command = cmWrap('"', cmRange(args).advance(3), '"', " ");
|
||||||
int retval = 0;
|
int retval = 0;
|
||||||
int timeout = 0;
|
int timeout = 0;
|
||||||
if ( cmSystemTools::RunSingleCommand(command.c_str(), 0, &retval,
|
if ( cmSystemTools::RunSingleCommand(command.c_str(), 0, 0, &retval,
|
||||||
directory.c_str(), cmSystemTools::OUTPUT_NORMAL, timeout) )
|
directory.c_str(), cmSystemTools::OUTPUT_NORMAL, timeout) )
|
||||||
{
|
{
|
||||||
return retval;
|
return retval;
|
||||||
@ -1350,7 +1350,7 @@ bool cmcmd::RunCommand(const char* comment,
|
|||||||
int retCode =0;
|
int retCode =0;
|
||||||
// use rc command to create .res file
|
// use rc command to create .res file
|
||||||
cmSystemTools::RunSingleCommand(command,
|
cmSystemTools::RunSingleCommand(command,
|
||||||
&output,
|
&output, &output,
|
||||||
&retCode, 0, cmSystemTools::OUTPUT_NONE);
|
&retCode, 0, cmSystemTools::OUTPUT_NONE);
|
||||||
// always print the output of the command, unless
|
// always print the output of the command, unless
|
||||||
// it is the dumb rc command banner, but if the command
|
// it is the dumb rc command banner, but if the command
|
||||||
|
@ -130,7 +130,7 @@ int main ()
|
|||||||
std::vector<std::string> command;
|
std::vector<std::string> command;
|
||||||
cmSystemTools::ParseUnixCommandLine(it->at("command").c_str(), command);
|
cmSystemTools::ParseUnixCommandLine(it->at("command").c_str(), command);
|
||||||
if (!cmSystemTools::RunSingleCommand(
|
if (!cmSystemTools::RunSingleCommand(
|
||||||
command, 0, 0, it->at("directory").c_str()))
|
command, 0, 0, 0, it->at("directory").c_str()))
|
||||||
{
|
{
|
||||||
std::cout << "ERROR: Failed to run command \""
|
std::cout << "ERROR: Failed to run command \""
|
||||||
<< command[0] << "\"" << std::endl;
|
<< command[0] << "\"" << std::endl;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user