mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-16 22:37:30 +08:00
cmSystemTools::RunSingleCommand: Accept std::string argument
This commit is contained in:
@@ -85,8 +85,8 @@ int cmCPackIFWGenerator::PackageFiles()
|
|||||||
int retVal = 1;
|
int retVal = 1;
|
||||||
cmCPackIFWLogger(OUTPUT, "- Generate repository" << std::endl);
|
cmCPackIFWLogger(OUTPUT, "- Generate repository" << std::endl);
|
||||||
bool res = cmSystemTools::RunSingleCommand(
|
bool res = cmSystemTools::RunSingleCommand(
|
||||||
ifwCmd.c_str(), &output, &output, &retVal, nullptr,
|
ifwCmd, &output, &output, &retVal, nullptr, this->GeneratorVerbose,
|
||||||
this->GeneratorVerbose, cmDuration::zero());
|
cmDuration::zero());
|
||||||
if (!res || retVal) {
|
if (!res || retVal) {
|
||||||
cmGeneratedFileStream ofs(ifwTmpFile);
|
cmGeneratedFileStream ofs(ifwTmpFile);
|
||||||
ofs << "# Run command: " << ifwCmd << std::endl
|
ofs << "# Run command: " << ifwCmd << std::endl
|
||||||
@@ -198,8 +198,8 @@ int cmCPackIFWGenerator::PackageFiles()
|
|||||||
int retVal = 1;
|
int retVal = 1;
|
||||||
cmCPackIFWLogger(OUTPUT, "- Generate package" << std::endl);
|
cmCPackIFWLogger(OUTPUT, "- Generate package" << std::endl);
|
||||||
bool res = cmSystemTools::RunSingleCommand(
|
bool res = cmSystemTools::RunSingleCommand(
|
||||||
ifwCmd.c_str(), &output, &output, &retVal, nullptr,
|
ifwCmd, &output, &output, &retVal, nullptr, this->GeneratorVerbose,
|
||||||
this->GeneratorVerbose, cmDuration::zero());
|
cmDuration::zero());
|
||||||
if (!res || retVal) {
|
if (!res || retVal) {
|
||||||
cmGeneratedFileStream ofs(ifwTmpFile);
|
cmGeneratedFileStream ofs(ifwTmpFile);
|
||||||
ofs << "# Run command: " << ifwCmd << std::endl
|
ofs << "# Run command: " << ifwCmd << std::endl
|
||||||
|
@@ -61,9 +61,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(
|
||||||
&output, &returnValue, 0,
|
command, &output, &output, &returnValue, 0, cmSystemTools::OUTPUT_NONE);
|
||||||
cmSystemTools::OUTPUT_NONE);
|
|
||||||
|
|
||||||
cmsys::ofstream logFile(logFileName.c_str(), std::ios::app);
|
cmsys::ofstream logFile(logFileName.c_str(), std::ios::app);
|
||||||
logFile << command << std::endl;
|
logFile << command << std::endl;
|
||||||
|
@@ -244,8 +244,8 @@ bool cmCPackDragNDropGenerator::RunCommand(std::ostringstream& command,
|
|||||||
int exit_code = 1;
|
int exit_code = 1;
|
||||||
|
|
||||||
bool result = cmSystemTools::RunSingleCommand(
|
bool result = cmSystemTools::RunSingleCommand(
|
||||||
command.str().c_str(), output, output, &exit_code, nullptr,
|
command.str(), output, output, &exit_code, nullptr, this->GeneratorVerbose,
|
||||||
this->GeneratorVerbose, cmDuration::zero());
|
cmDuration::zero());
|
||||||
|
|
||||||
if (!result || exit_code) {
|
if (!result || exit_code) {
|
||||||
cmCPackLogger(cmCPackLog::LOG_ERROR,
|
cmCPackLogger(cmCPackLog::LOG_ERROR,
|
||||||
|
@@ -278,7 +278,7 @@ int cmCPackGenerator::InstallProjectViaInstallCommands(
|
|||||||
std::string output;
|
std::string output;
|
||||||
int retVal = 1;
|
int retVal = 1;
|
||||||
bool resB = cmSystemTools::RunSingleCommand(
|
bool resB = cmSystemTools::RunSingleCommand(
|
||||||
ic.c_str(), &output, &output, &retVal, nullptr, this->GeneratorVerbose,
|
ic, &output, &output, &retVal, nullptr, this->GeneratorVerbose,
|
||||||
cmDuration::zero());
|
cmDuration::zero());
|
||||||
if (!resB || retVal) {
|
if (!resB || retVal) {
|
||||||
std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
|
std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
|
||||||
@@ -647,8 +647,8 @@ int cmCPackGenerator::RunPreinstallTarget(
|
|||||||
std::string output;
|
std::string output;
|
||||||
int retVal = 1;
|
int retVal = 1;
|
||||||
bool resB = cmSystemTools::RunSingleCommand(
|
bool resB = cmSystemTools::RunSingleCommand(
|
||||||
buildCommand.c_str(), &output, &output, &retVal,
|
buildCommand, &output, &output, &retVal, installDirectory.c_str(),
|
||||||
installDirectory.c_str(), this->GeneratorVerbose, cmDuration::zero());
|
this->GeneratorVerbose, cmDuration::zero());
|
||||||
if (!resB || retVal) {
|
if (!resB || retVal) {
|
||||||
std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
|
std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
|
||||||
tmpFile += "/PreinstallOutput.log";
|
tmpFile += "/PreinstallOutput.log";
|
||||||
|
@@ -302,8 +302,8 @@ int cmCPackNSISGenerator::PackageFiles()
|
|||||||
std::string output;
|
std::string output;
|
||||||
int retVal = 1;
|
int retVal = 1;
|
||||||
bool res = cmSystemTools::RunSingleCommand(
|
bool res = cmSystemTools::RunSingleCommand(
|
||||||
nsisCmd.c_str(), &output, &output, &retVal, nullptr,
|
nsisCmd, &output, &output, &retVal, nullptr, this->GeneratorVerbose,
|
||||||
this->GeneratorVerbose, cmDuration::zero());
|
cmDuration::zero());
|
||||||
if (!res || retVal) {
|
if (!res || retVal) {
|
||||||
cmGeneratedFileStream ofs(tmpFile);
|
cmGeneratedFileStream ofs(tmpFile);
|
||||||
ofs << "# Run command: " << nsisCmd << std::endl
|
ofs << "# Run command: " << nsisCmd << std::endl
|
||||||
@@ -407,8 +407,8 @@ int cmCPackNSISGenerator::InitializeInternal()
|
|||||||
std::string output;
|
std::string output;
|
||||||
int retVal = 1;
|
int retVal = 1;
|
||||||
bool resS = cmSystemTools::RunSingleCommand(
|
bool resS = cmSystemTools::RunSingleCommand(
|
||||||
nsisCmd.c_str(), &output, &output, &retVal, nullptr,
|
nsisCmd, &output, &output, &retVal, nullptr, this->GeneratorVerbose,
|
||||||
this->GeneratorVerbose, cmDuration::zero());
|
cmDuration::zero());
|
||||||
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 ||
|
||||||
@@ -749,7 +749,7 @@ std::string cmCPackNSISGenerator::CreateComponentDescription(
|
|||||||
std::string output;
|
std::string output;
|
||||||
int retVal = -1;
|
int retVal = -1;
|
||||||
int res = cmSystemTools::RunSingleCommand(
|
int res = cmSystemTools::RunSingleCommand(
|
||||||
cmd.c_str(), &output, &output, &retVal, dirName.c_str(),
|
cmd, &output, &output, &retVal, dirName.c_str(),
|
||||||
cmSystemTools::OUTPUT_NONE, cmDuration::zero());
|
cmSystemTools::OUTPUT_NONE, cmDuration::zero());
|
||||||
if (!res || retVal) {
|
if (!res || retVal) {
|
||||||
std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
|
std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
|
||||||
|
@@ -155,8 +155,8 @@ int cmCPackOSXX11Generator::PackageFiles()
|
|||||||
bool res = false;
|
bool res = false;
|
||||||
while (numTries > 0) {
|
while (numTries > 0) {
|
||||||
res = cmSystemTools::RunSingleCommand(
|
res = cmSystemTools::RunSingleCommand(
|
||||||
dmgCmd.str().c_str(), &output, &output, &retVal, nullptr,
|
dmgCmd.str(), &output, &output, &retVal, nullptr, this->GeneratorVerbose,
|
||||||
this->GeneratorVerbose, cmDuration::zero());
|
cmDuration::zero());
|
||||||
if (res && !retVal) {
|
if (res && !retVal) {
|
||||||
numTries = -1;
|
numTries = -1;
|
||||||
break;
|
break;
|
||||||
|
@@ -295,8 +295,8 @@ int cmCPackPackageMakerGenerator::PackageFiles()
|
|||||||
bool res = false;
|
bool res = false;
|
||||||
while (numTries > 0) {
|
while (numTries > 0) {
|
||||||
res = cmSystemTools::RunSingleCommand(
|
res = cmSystemTools::RunSingleCommand(
|
||||||
dmgCmd.str().c_str(), &output, &output, &retVal, nullptr,
|
dmgCmd.str(), &output, &output, &retVal, nullptr, this->GeneratorVerbose,
|
||||||
this->GeneratorVerbose, cmDuration::zero());
|
cmDuration::zero());
|
||||||
if (res && !retVal) {
|
if (res && !retVal) {
|
||||||
numTries = -1;
|
numTries = -1;
|
||||||
break;
|
break;
|
||||||
|
@@ -145,8 +145,8 @@ bool cmCPackProductBuildGenerator::RunProductBuild(const std::string& command)
|
|||||||
std::string output;
|
std::string output;
|
||||||
int retVal = 1;
|
int retVal = 1;
|
||||||
bool res = cmSystemTools::RunSingleCommand(
|
bool res = cmSystemTools::RunSingleCommand(
|
||||||
command.c_str(), &output, &output, &retVal, nullptr,
|
command, &output, &output, &retVal, nullptr, this->GeneratorVerbose,
|
||||||
this->GeneratorVerbose, cmDuration::zero());
|
cmDuration::zero());
|
||||||
cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Done running command" << std::endl);
|
cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Done running command" << std::endl);
|
||||||
if (!res || retVal) {
|
if (!res || retVal) {
|
||||||
cmGeneratedFileStream ofs(tmpFile);
|
cmGeneratedFileStream ofs(tmpFile);
|
||||||
|
@@ -607,9 +607,8 @@ int cmCTestScriptHandler::CheckOutSourceDir()
|
|||||||
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(
|
res = cmSystemTools::RunSingleCommand(
|
||||||
this->CVSCheckOut.c_str(), &output, &output, &retVal,
|
this->CVSCheckOut, &output, &output, &retVal, this->CTestRoot.c_str(),
|
||||||
this->CTestRoot.c_str(), this->HandlerVerbose,
|
this->HandlerVerbose, cmDuration::zero() /*this->TimeOut*/);
|
||||||
cmDuration::zero() /*this->TimeOut*/);
|
|
||||||
if (!res || retVal != 0) {
|
if (!res || retVal != 0) {
|
||||||
cmSystemTools::Error("Unable to perform cvs checkout:\n",
|
cmSystemTools::Error("Unable to perform cvs checkout:\n",
|
||||||
output.c_str());
|
output.c_str());
|
||||||
@@ -675,7 +674,7 @@ int cmCTestScriptHandler::PerformExtraUpdates()
|
|||||||
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
|
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
|
||||||
"Run Update: " << fullCommand << std::endl);
|
"Run Update: " << fullCommand << std::endl);
|
||||||
res = cmSystemTools::RunSingleCommand(
|
res = cmSystemTools::RunSingleCommand(
|
||||||
fullCommand.c_str(), &output, &output, &retVal, cvsArgs[0].c_str(),
|
fullCommand, &output, &output, &retVal, cvsArgs[0].c_str(),
|
||||||
this->HandlerVerbose, cmDuration::zero() /*this->TimeOut*/);
|
this->HandlerVerbose, cmDuration::zero() /*this->TimeOut*/);
|
||||||
if (!res || retVal != 0) {
|
if (!res || retVal != 0) {
|
||||||
cmSystemTools::Error("Unable to perform extra updates:\n", eu.c_str(),
|
cmSystemTools::Error("Unable to perform extra updates:\n", eu.c_str(),
|
||||||
@@ -779,7 +778,7 @@ int cmCTestScriptHandler::RunConfigurationDashboard()
|
|||||||
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
|
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
|
||||||
"Run cmake command: " << command << std::endl);
|
"Run cmake command: " << command << std::endl);
|
||||||
res = cmSystemTools::RunSingleCommand(
|
res = cmSystemTools::RunSingleCommand(
|
||||||
command.c_str(), &output, &output, &retVal, this->BinaryDir.c_str(),
|
command, &output, &output, &retVal, this->BinaryDir.c_str(),
|
||||||
this->HandlerVerbose, cmDuration::zero() /*this->TimeOut*/);
|
this->HandlerVerbose, cmDuration::zero() /*this->TimeOut*/);
|
||||||
|
|
||||||
if (!this->CMOutFile.empty()) {
|
if (!this->CMOutFile.empty()) {
|
||||||
@@ -818,7 +817,7 @@ int cmCTestScriptHandler::RunConfigurationDashboard()
|
|||||||
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
|
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
|
||||||
"Run ctest command: " << command << std::endl);
|
"Run ctest command: " << command << std::endl);
|
||||||
res = cmSystemTools::RunSingleCommand(
|
res = cmSystemTools::RunSingleCommand(
|
||||||
command.c_str(), &output, &output, &retVal, this->BinaryDir.c_str(),
|
command, &output, &output, &retVal, this->BinaryDir.c_str(),
|
||||||
this->HandlerVerbose, cmDuration::zero() /*this->TimeOut*/);
|
this->HandlerVerbose, cmDuration::zero() /*this->TimeOut*/);
|
||||||
|
|
||||||
// did something critical fail in ctest
|
// did something critical fail in ctest
|
||||||
|
@@ -1486,7 +1486,7 @@ int cmCTestTestHandler::ExecuteCommands(std::vector<std::string>& vec)
|
|||||||
int retVal = 0;
|
int retVal = 0;
|
||||||
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
|
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
|
||||||
"Run command: " << it << std::endl, this->Quiet);
|
"Run command: " << it << std::endl, this->Quiet);
|
||||||
if (!cmSystemTools::RunSingleCommand(it.c_str(), nullptr, nullptr, &retVal,
|
if (!cmSystemTools::RunSingleCommand(it, nullptr, nullptr, &retVal,
|
||||||
nullptr, cmSystemTools::OUTPUT_MERGE
|
nullptr, cmSystemTools::OUTPUT_MERGE
|
||||||
/*this->Verbose*/) ||
|
/*this->Verbose*/) ||
|
||||||
retVal != 0) {
|
retVal != 0) {
|
||||||
|
@@ -52,9 +52,8 @@ bool cmSiteNameCommand::InitialPass(std::vector<std::string> const& args,
|
|||||||
// try to find the hostname for this computer
|
// try to find the hostname for this computer
|
||||||
if (!cmSystemTools::IsOff(hostname_cmd)) {
|
if (!cmSystemTools::IsOff(hostname_cmd)) {
|
||||||
std::string host;
|
std::string host;
|
||||||
cmSystemTools::RunSingleCommand(hostname_cmd.c_str(), &host, nullptr,
|
cmSystemTools::RunSingleCommand(hostname_cmd, &host, nullptr, nullptr,
|
||||||
nullptr, nullptr,
|
nullptr, cmSystemTools::OUTPUT_NONE);
|
||||||
cmSystemTools::OUTPUT_NONE);
|
|
||||||
|
|
||||||
// got the hostname
|
// got the hostname
|
||||||
if (!host.empty()) {
|
if (!host.empty()) {
|
||||||
|
@@ -867,7 +867,7 @@ bool cmSystemTools::RunSingleCommand(std::vector<std::string> const& command,
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cmSystemTools::RunSingleCommand(const char* command,
|
bool cmSystemTools::RunSingleCommand(const std::string& command,
|
||||||
std::string* captureStdOut,
|
std::string* captureStdOut,
|
||||||
std::string* captureStdErr, int* retVal,
|
std::string* captureStdErr, int* retVal,
|
||||||
const char* dir, OutputOption outputflag,
|
const char* dir, OutputOption outputflag,
|
||||||
@@ -877,7 +877,8 @@ bool cmSystemTools::RunSingleCommand(const char* command,
|
|||||||
outputflag = OUTPUT_NONE;
|
outputflag = OUTPUT_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::string> args = cmSystemTools::ParseArguments(command);
|
std::vector<std::string> args =
|
||||||
|
cmSystemTools::ParseArguments(command.c_str());
|
||||||
|
|
||||||
if (args.empty()) {
|
if (args.empty()) {
|
||||||
return false;
|
return false;
|
||||||
|
@@ -224,7 +224,7 @@ public:
|
|||||||
OUTPUT_FORWARD,
|
OUTPUT_FORWARD,
|
||||||
OUTPUT_PASSTHROUGH
|
OUTPUT_PASSTHROUGH
|
||||||
};
|
};
|
||||||
static bool RunSingleCommand(const char* command,
|
static bool RunSingleCommand(const std::string& command,
|
||||||
std::string* captureStdOut = nullptr,
|
std::string* captureStdOut = nullptr,
|
||||||
std::string* captureStdErr = nullptr,
|
std::string* captureStdErr = nullptr,
|
||||||
int* retVal = nullptr,
|
int* retVal = nullptr,
|
||||||
|
@@ -189,8 +189,8 @@ void cmTryRunCommand::RunExecutable(const std::string& runArgs,
|
|||||||
finalCommand += runArgs;
|
finalCommand += runArgs;
|
||||||
}
|
}
|
||||||
bool worked = cmSystemTools::RunSingleCommand(
|
bool worked = cmSystemTools::RunSingleCommand(
|
||||||
finalCommand.c_str(), out, out, &retVal, nullptr,
|
finalCommand, out, out, &retVal, nullptr, cmSystemTools::OUTPUT_NONE,
|
||||||
cmSystemTools::OUTPUT_NONE, cmDuration::zero());
|
cmDuration::zero());
|
||||||
// set the run var
|
// set the run var
|
||||||
char retChar[16];
|
char retChar[16];
|
||||||
const char* retStr;
|
const char* retStr;
|
||||||
|
@@ -826,7 +826,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
|
|||||||
cmWrap('"', cmMakeRange(args).advance(3), '"', " ");
|
cmWrap('"', cmMakeRange(args).advance(3), '"', " ");
|
||||||
int retval = 0;
|
int retval = 0;
|
||||||
if (cmSystemTools::RunSingleCommand(
|
if (cmSystemTools::RunSingleCommand(
|
||||||
command.c_str(), nullptr, nullptr, &retval, directory.c_str(),
|
command, nullptr, nullptr, &retval, directory.c_str(),
|
||||||
cmSystemTools::OUTPUT_PASSTHROUGH, cmDuration::zero())) {
|
cmSystemTools::OUTPUT_PASSTHROUGH, cmDuration::zero())) {
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user