Commit 65baaa0e authored by Vitaly Stakhovsky's avatar Vitaly Stakhovsky

cmSystemTools::RunSingleCommand: Accept std::string argument

parent 062cfd99
......@@ -85,8 +85,8 @@ int cmCPackIFWGenerator::PackageFiles()
int retVal = 1;
cmCPackIFWLogger(OUTPUT, "- Generate repository" << std::endl);
bool res = cmSystemTools::RunSingleCommand(
ifwCmd.c_str(), &output, &output, &retVal, nullptr,
this->GeneratorVerbose, cmDuration::zero());
ifwCmd, &output, &output, &retVal, nullptr, this->GeneratorVerbose,
cmDuration::zero());
if (!res || retVal) {
cmGeneratedFileStream ofs(ifwTmpFile);
ofs << "# Run command: " << ifwCmd << std::endl
......@@ -198,8 +198,8 @@ int cmCPackIFWGenerator::PackageFiles()
int retVal = 1;
cmCPackIFWLogger(OUTPUT, "- Generate package" << std::endl);
bool res = cmSystemTools::RunSingleCommand(
ifwCmd.c_str(), &output, &output, &retVal, nullptr,
this->GeneratorVerbose, cmDuration::zero());
ifwCmd, &output, &output, &retVal, nullptr, this->GeneratorVerbose,
cmDuration::zero());
if (!res || retVal) {
cmGeneratedFileStream ofs(ifwTmpFile);
ofs << "# Run command: " << ifwCmd << std::endl
......
......@@ -61,9 +61,8 @@ bool cmCPackWIXGenerator::RunWiXCommand(std::string const& command)
std::string output;
int returnValue = 0;
bool status = cmSystemTools::RunSingleCommand(command.c_str(), &output,
&output, &returnValue, 0,
cmSystemTools::OUTPUT_NONE);
bool status = cmSystemTools::RunSingleCommand(
command, &output, &output, &returnValue, 0, cmSystemTools::OUTPUT_NONE);
cmsys::ofstream logFile(logFileName.c_str(), std::ios::app);
logFile << command << std::endl;
......
......@@ -244,8 +244,8 @@ bool cmCPackDragNDropGenerator::RunCommand(std::ostringstream& command,
int exit_code = 1;
bool result = cmSystemTools::RunSingleCommand(
command.str().c_str(), output, output, &exit_code, nullptr,
this->GeneratorVerbose, cmDuration::zero());
command.str(), output, output, &exit_code, nullptr, this->GeneratorVerbose,
cmDuration::zero());
if (!result || exit_code) {
cmCPackLogger(cmCPackLog::LOG_ERROR,
......
......@@ -278,7 +278,7 @@ int cmCPackGenerator::InstallProjectViaInstallCommands(
std::string output;
int retVal = 1;
bool resB = cmSystemTools::RunSingleCommand(
ic.c_str(), &output, &output, &retVal, nullptr, this->GeneratorVerbose,
ic, &output, &output, &retVal, nullptr, this->GeneratorVerbose,
cmDuration::zero());
if (!resB || retVal) {
std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
......@@ -647,8 +647,8 @@ int cmCPackGenerator::RunPreinstallTarget(
std::string output;
int retVal = 1;
bool resB = cmSystemTools::RunSingleCommand(
buildCommand.c_str(), &output, &output, &retVal,
installDirectory.c_str(), this->GeneratorVerbose, cmDuration::zero());
buildCommand, &output, &output, &retVal, installDirectory.c_str(),
this->GeneratorVerbose, cmDuration::zero());
if (!resB || retVal) {
std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
tmpFile += "/PreinstallOutput.log";
......
......@@ -302,8 +302,8 @@ int cmCPackNSISGenerator::PackageFiles()
std::string output;
int retVal = 1;
bool res = cmSystemTools::RunSingleCommand(
nsisCmd.c_str(), &output, &output, &retVal, nullptr,
this->GeneratorVerbose, cmDuration::zero());
nsisCmd, &output, &output, &retVal, nullptr, this->GeneratorVerbose,
cmDuration::zero());
if (!res || retVal) {
cmGeneratedFileStream ofs(tmpFile);
ofs << "# Run command: " << nsisCmd << std::endl
......@@ -407,8 +407,8 @@ int cmCPackNSISGenerator::InitializeInternal()
std::string output;
int retVal = 1;
bool resS = cmSystemTools::RunSingleCommand(
nsisCmd.c_str(), &output, &output, &retVal, nullptr,
this->GeneratorVerbose, cmDuration::zero());
nsisCmd, &output, &output, &retVal, nullptr, this->GeneratorVerbose,
cmDuration::zero());
cmsys::RegularExpression versionRex("v([0-9]+.[0-9]+)");
cmsys::RegularExpression versionRexCVS("v(.*)\\.cvs");
if (!resS || retVal ||
......@@ -749,7 +749,7 @@ std::string cmCPackNSISGenerator::CreateComponentDescription(
std::string output;
int retVal = -1;
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());
if (!res || retVal) {
std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
......
......@@ -155,8 +155,8 @@ int cmCPackOSXX11Generator::PackageFiles()
bool res = false;
while (numTries > 0) {
res = cmSystemTools::RunSingleCommand(
dmgCmd.str().c_str(), &output, &output, &retVal, nullptr,
this->GeneratorVerbose, cmDuration::zero());
dmgCmd.str(), &output, &output, &retVal, nullptr, this->GeneratorVerbose,
cmDuration::zero());
if (res && !retVal) {
numTries = -1;
break;
......
......@@ -295,8 +295,8 @@ int cmCPackPackageMakerGenerator::PackageFiles()
bool res = false;
while (numTries > 0) {
res = cmSystemTools::RunSingleCommand(
dmgCmd.str().c_str(), &output, &output, &retVal, nullptr,
this->GeneratorVerbose, cmDuration::zero());
dmgCmd.str(), &output, &output, &retVal, nullptr, this->GeneratorVerbose,
cmDuration::zero());
if (res && !retVal) {
numTries = -1;
break;
......
......@@ -145,8 +145,8 @@ bool cmCPackProductBuildGenerator::RunProductBuild(const std::string& command)
std::string output;
int retVal = 1;
bool res = cmSystemTools::RunSingleCommand(
command.c_str(), &output, &output, &retVal, nullptr,
this->GeneratorVerbose, cmDuration::zero());
command, &output, &output, &retVal, nullptr, this->GeneratorVerbose,
cmDuration::zero());
cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Done running command" << std::endl);
if (!res || retVal) {
cmGeneratedFileStream ofs(tmpFile);
......
......@@ -607,9 +607,8 @@ int cmCTestScriptHandler::CheckOutSourceDir()
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
"Run cvs: " << this->CVSCheckOut << std::endl);
res = cmSystemTools::RunSingleCommand(
this->CVSCheckOut.c_str(), &output, &output, &retVal,
this->CTestRoot.c_str(), this->HandlerVerbose,
cmDuration::zero() /*this->TimeOut*/);
this->CVSCheckOut, &output, &output, &retVal, this->CTestRoot.c_str(),
this->HandlerVerbose, cmDuration::zero() /*this->TimeOut*/);
if (!res || retVal != 0) {
cmSystemTools::Error("Unable to perform cvs checkout:\n",
output.c_str());
......@@ -675,7 +674,7 @@ int cmCTestScriptHandler::PerformExtraUpdates()
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
"Run Update: " << fullCommand << std::endl);
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*/);
if (!res || retVal != 0) {
cmSystemTools::Error("Unable to perform extra updates:\n", eu.c_str(),
......@@ -779,7 +778,7 @@ int cmCTestScriptHandler::RunConfigurationDashboard()
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
"Run cmake command: " << command << std::endl);
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*/);
if (!this->CMOutFile.empty()) {
......@@ -818,7 +817,7 @@ int cmCTestScriptHandler::RunConfigurationDashboard()
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
"Run ctest command: " << command << std::endl);
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*/);
// did something critical fail in ctest
......
......@@ -1486,7 +1486,7 @@ int cmCTestTestHandler::ExecuteCommands(std::vector<std::string>& vec)
int retVal = 0;
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
"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
/*this->Verbose*/) ||
retVal != 0) {
......
......@@ -52,9 +52,8 @@ bool cmSiteNameCommand::InitialPass(std::vector<std::string> const& args,
// try to find the hostname for this computer
if (!cmSystemTools::IsOff(hostname_cmd)) {
std::string host;
cmSystemTools::RunSingleCommand(hostname_cmd.c_str(), &host, nullptr,
nullptr, nullptr,
cmSystemTools::OUTPUT_NONE);
cmSystemTools::RunSingleCommand(hostname_cmd, &host, nullptr, nullptr,
nullptr, cmSystemTools::OUTPUT_NONE);
// got the hostname
if (!host.empty()) {
......
......@@ -867,7 +867,7 @@ bool cmSystemTools::RunSingleCommand(std::vector<std::string> const& command,
return result;
}
bool cmSystemTools::RunSingleCommand(const char* command,
bool cmSystemTools::RunSingleCommand(const std::string& command,
std::string* captureStdOut,
std::string* captureStdErr, int* retVal,
const char* dir, OutputOption outputflag,
......@@ -877,7 +877,8 @@ bool cmSystemTools::RunSingleCommand(const char* command,
outputflag = OUTPUT_NONE;
}
std::vector<std::string> args = cmSystemTools::ParseArguments(command);
std::vector<std::string> args =
cmSystemTools::ParseArguments(command.c_str());
if (args.empty()) {
return false;
......
......@@ -224,7 +224,7 @@ public:
OUTPUT_FORWARD,
OUTPUT_PASSTHROUGH
};
static bool RunSingleCommand(const char* command,
static bool RunSingleCommand(const std::string& command,
std::string* captureStdOut = nullptr,
std::string* captureStdErr = nullptr,
int* retVal = nullptr,
......
......@@ -189,8 +189,8 @@ void cmTryRunCommand::RunExecutable(const std::string& runArgs,
finalCommand += runArgs;
}
bool worked = cmSystemTools::RunSingleCommand(
finalCommand.c_str(), out, out, &retVal, nullptr,
cmSystemTools::OUTPUT_NONE, cmDuration::zero());
finalCommand, out, out, &retVal, nullptr, cmSystemTools::OUTPUT_NONE,
cmDuration::zero());
// set the run var
char retChar[16];
const char* retStr;
......
......@@ -826,7 +826,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
cmWrap('"', cmMakeRange(args).advance(3), '"', " ");
int retval = 0;
if (cmSystemTools::RunSingleCommand(
command.c_str(), nullptr, nullptr, &retval, directory.c_str(),
command, nullptr, nullptr, &retval, directory.c_str(),
cmSystemTools::OUTPUT_PASSTHROUGH, cmDuration::zero())) {
return retval;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment