Commit 4e315e94 authored by Vitaly Stakhovsky's avatar Vitaly Stakhovsky

cmSystemTools: More functions accept `std::string` params

parent b76b83ef
......@@ -1255,9 +1255,8 @@ bool cmCPackGenerator::ConfigureFile(const std::string& inName,
int cmCPackGenerator::CleanTemporaryDirectory()
{
std::string tempInstallDirectoryWithPostfix =
std::string tempInstallDirectory =
this->GetOption("CPACK_TEMPORARY_INSTALL_DIRECTORY");
const char* tempInstallDirectory = tempInstallDirectoryWithPostfix.c_str();
if (cmsys::SystemTools::FileExists(tempInstallDirectory)) {
cmCPackLogger(cmCPackLog::LOG_OUTPUT,
"- Clean temporary : " << tempInstallDirectory << std::endl);
......
......@@ -365,7 +365,7 @@ bool cmCTestBZR::UpdateImpl()
if (opts.empty()) {
opts = this->CTest->GetCTestConfiguration("BZRUpdateOptions");
}
std::vector<std::string> args = cmSystemTools::ParseArguments(opts.c_str());
std::vector<std::string> args = cmSystemTools::ParseArguments(opts);
// TODO: if(this->CTest->GetTestModel() == cmCTest::NIGHTLY)
......
......@@ -418,8 +418,8 @@ int cmCTestBuildHandler::ProcessHandler()
int retVal = 0;
int res = cmsysProcess_State_Exited;
if (!this->CTest->GetShowOnly()) {
res = this->RunMakeCommand(makeCommand.c_str(), &retVal,
buildDirectory.c_str(), 0, ofs);
res = this->RunMakeCommand(makeCommand, &retVal, buildDirectory.c_str(), 0,
ofs);
} else {
cmCTestOptionalLog(this->CTest, DEBUG,
"Build with command: " << makeCommand << std::endl,
......@@ -766,9 +766,10 @@ void cmCTestBuildHandler::LaunchHelper::WriteScrapeMatchers(
}
}
int cmCTestBuildHandler::RunMakeCommand(const char* command, int* retVal,
const char* dir, int timeout,
std::ostream& ofs, Encoding encoding)
int cmCTestBuildHandler::RunMakeCommand(const std::string& command,
int* retVal, const char* dir,
int timeout, std::ostream& ofs,
Encoding encoding)
{
// First generate the command and arguments
std::vector<std::string> args = cmSystemTools::ParseArguments(command);
......
......@@ -52,7 +52,7 @@ private:
//! Run command specialized for make and configure. Returns process status
// and retVal is return value or exception.
int RunMakeCommand(const char* command, int* retVal, const char* dir,
int RunMakeCommand(const std::string& command, int* retVal, const char* dir,
int timeout, std::ostream& ofs,
Encoding encoding = cmProcessOutput::Auto);
......
......@@ -78,7 +78,7 @@ bool cmCTestCVS::UpdateImpl()
opts = "-dP";
}
}
std::vector<std::string> args = cmSystemTools::ParseArguments(opts.c_str());
std::vector<std::string> args = cmSystemTools::ParseArguments(opts);
// Specify the start time for nightly testing.
if (this->CTest->GetTestModel() == cmCTest::NIGHTLY) {
......
......@@ -61,7 +61,7 @@ int cmCTestConfigureHandler::ProcessHandler()
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
"Configure with command: " << cCommand << std::endl,
this->Quiet);
res = this->CTest->RunMakeCommand(cCommand.c_str(), output, &retVal,
res = this->CTest->RunMakeCommand(cCommand, output, &retVal,
buildDirectory.c_str(),
cmDuration::zero(), ofs);
......
......@@ -1004,7 +1004,7 @@ int cmCTestCoverageHandler::HandleGCovCoverage(
static_cast<void>(locale_C);
std::vector<std::string> basecovargs =
cmSystemTools::ParseArguments(gcovExtraFlags.c_str());
cmSystemTools::ParseArguments(gcovExtraFlags);
basecovargs.insert(basecovargs.begin(), gcovCommand);
basecovargs.emplace_back("-o");
......@@ -1377,7 +1377,7 @@ int cmCTestCoverageHandler::HandleLCovCoverage(
static_cast<void>(locale_C);
std::vector<std::string> covargs =
cmSystemTools::ParseArguments(lcovExtraFlags.c_str());
cmSystemTools::ParseArguments(lcovExtraFlags);
covargs.insert(covargs.begin(), lcovCommand);
const std::string command = joinCommandLine(covargs);
......
......@@ -162,7 +162,7 @@ bool cmCTestGIT::UpdateByFetchAndReset()
if (opts.empty()) {
opts = this->CTest->GetCTestConfiguration("GITUpdateOptions");
}
std::vector<std::string> args = cmSystemTools::ParseArguments(opts.c_str());
std::vector<std::string> args = cmSystemTools::ParseArguments(opts);
for (std::string const& arg : args) {
git_fetch.push_back(arg.c_str());
}
......
......@@ -144,7 +144,7 @@ bool cmCTestHG::UpdateImpl()
if (opts.empty()) {
opts = this->CTest->GetCTestConfiguration("HGUpdateOptions");
}
std::vector<std::string> args = cmSystemTools::ParseArguments(opts.c_str());
std::vector<std::string> args = cmSystemTools::ParseArguments(opts);
for (std::string const& arg : args) {
hg_update.push_back(arg.c_str());
}
......
......@@ -520,7 +520,7 @@ bool cmCTestMemCheckHandler::InitializeMemoryChecking()
this->CTest->GetCTestConfiguration("ValgrindCommandOptions");
}
this->MemoryTesterOptions =
cmSystemTools::ParseArguments(memoryTesterOptions.c_str());
cmSystemTools::ParseArguments(memoryTesterOptions);
this->MemoryTesterOutputFile =
this->CTest->GetBinaryDir() + "/Testing/Temporary/MemoryChecker.??.log";
......
......@@ -324,8 +324,7 @@ void cmCTestP4::SetP4Options(std::vector<char const*>& CommandOptions)
// The CTEST_P4_OPTIONS variable adds additional Perforce command line
// options before the main command
std::string opts = this->CTest->GetCTestConfiguration("P4Options");
std::vector<std::string> args =
cmSystemTools::ParseArguments(opts.c_str());
std::vector<std::string> args = cmSystemTools::ParseArguments(opts);
P4Options.insert(P4Options.end(), args.begin(), args.end());
}
......@@ -501,7 +500,7 @@ bool cmCTestP4::UpdateImpl()
if (opts.empty()) {
opts = this->CTest->GetCTestConfiguration("P4UpdateOptions");
}
std::vector<std::string> args = cmSystemTools::ParseArguments(opts.c_str());
std::vector<std::string> args = cmSystemTools::ParseArguments(opts);
for (std::string const& arg : args) {
p4_sync.push_back(arg.c_str());
}
......
......@@ -242,7 +242,7 @@ bool cmCTestSVN::UpdateImpl()
if (opts.empty()) {
opts = this->CTest->GetCTestConfiguration("SVNUpdateOptions");
}
std::vector<std::string> args = cmSystemTools::ParseArguments(opts.c_str());
std::vector<std::string> args = cmSystemTools::ParseArguments(opts);
// Specify the start time for nightly testing.
if (this->CTest->GetTestModel() == cmCTest::NIGHTLY) {
......@@ -277,7 +277,7 @@ bool cmCTestSVN::RunSVNCommand(std::vector<char const*> const& parameters,
std::string userOptions = this->CTest->GetCTestConfiguration("SVNOptions");
std::vector<std::string> parsedUserOptions =
cmSystemTools::ParseArguments(userOptions.c_str());
cmSystemTools::ParseArguments(userOptions);
for (std::string const& opt : parsedUserOptions) {
args.push_back(opt.c_str());
}
......
......@@ -1009,7 +1009,7 @@ int cmCTest::GetTestModelFromString(const char* str)
//######################################################################
//######################################################################
int cmCTest::RunMakeCommand(const char* command, std::string& output,
int cmCTest::RunMakeCommand(const std::string& command, std::string& output,
int* retVal, const char* dir, cmDuration timeout,
std::ostream& ofs, Encoding encoding)
{
......
......@@ -280,8 +280,9 @@ public:
* Run command specialized for make and configure. Returns process status
* and retVal is return value or exception.
*/
int RunMakeCommand(const char* command, std::string& output, int* retVal,
const char* dir, cmDuration timeout, std::ostream& ofs,
int RunMakeCommand(const std::string& command, std::string& output,
int* retVal, const char* dir, cmDuration timeout,
std::ostream& ofs,
Encoding encoding = cmProcessOutput::Auto);
/** Return the current tag */
......
......@@ -1266,7 +1266,7 @@ void cmComputeLinkInformation::AddFrameworkItem(std::string const& item)
void cmComputeLinkInformation::AddDirectoryItem(std::string const& item)
{
if (this->Makefile->IsOn("APPLE") &&
cmSystemTools::IsPathToFramework(item.c_str())) {
cmSystemTools::IsPathToFramework(item)) {
this->AddFrameworkItem(item);
} else {
this->DropDirectoryItem(item);
......
......@@ -67,7 +67,7 @@ bool cmExecProgramCommand::InitialPass(std::vector<std::string> const& args,
std::string command;
if (!arguments.empty()) {
command = cmSystemTools::ConvertToRunCommandPath(args[0].c_str());
command = cmSystemTools::ConvertToRunCommandPath(args[0]);
command += " ";
command += arguments;
} else {
......
......@@ -210,7 +210,7 @@ void cmGhsMultiTargetGenerator::WriteCompilerFlags(std::ostream& fout,
if (flagsByLangI != this->FlagsByLanguage.end()) {
if (!flagsByLangI->second.empty()) {
std::vector<std::string> ghsCompFlags =
cmSystemTools::ParseArguments(flagsByLangI->second.c_str());
cmSystemTools::ParseArguments(flagsByLangI->second);
for (auto& f : ghsCompFlags) {
fout << " " << f << std::endl;
}
......@@ -265,16 +265,14 @@ void cmGhsMultiTargetGenerator::WriteTargetLinkLine(std::ostream& fout,
frameworkPath, linkPath, this->GeneratorTarget);
// write out link options
std::vector<std::string> lopts =
cmSystemTools::ParseArguments(linkFlags.c_str());
std::vector<std::string> lopts = cmSystemTools::ParseArguments(linkFlags);
for (auto& l : lopts) {
fout << " " << l << std::endl;
}
// write out link search paths
// must be quoted for paths that contain spaces
std::vector<std::string> lpath =
cmSystemTools::ParseArguments(linkPath.c_str());
std::vector<std::string> lpath = cmSystemTools::ParseArguments(linkPath);
for (auto& l : lpath) {
fout << " -L\"" << l << "\"" << std::endl;
}
......@@ -284,7 +282,7 @@ void cmGhsMultiTargetGenerator::WriteTargetLinkLine(std::ostream& fout,
std::string cbd = this->LocalGenerator->GetCurrentBinaryDirectory();
std::vector<std::string> llibs =
cmSystemTools::ParseArguments(linkLibraries.c_str());
cmSystemTools::ParseArguments(linkLibraries);
for (auto& l : llibs) {
if (l.compare(0, 2, "-l") == 0) {
fout << " \"" << l << "\"" << std::endl;
......
......@@ -2200,7 +2200,7 @@ cmGeneratorTarget* cmGlobalGenerator::FindGeneratorTarget(
bool cmGlobalGenerator::NameResolvesToFramework(
const std::string& libname) const
{
if (cmSystemTools::IsPathToFramework(libname.c_str())) {
if (cmSystemTools::IsPathToFramework(libname)) {
return true;
}
......
......@@ -776,7 +776,7 @@ std::string cmLocalGenerator::GetIncludeFlags(
#endif
for (std::string const& i : includes) {
if (fwSearchFlag && *fwSearchFlag && this->Makefile->IsOn("APPLE") &&
cmSystemTools::IsPathToFramework(i.c_str())) {
cmSystemTools::IsPathToFramework(i)) {
std::string frameworkDir = i;
frameworkDir += "/../";
frameworkDir = cmSystemTools::CollapseFullPath(frameworkDir);
......
......@@ -571,13 +571,14 @@ std::vector<std::string> cmSystemTools::HandleResponseFile(
return arg_full;
}
std::vector<std::string> cmSystemTools::ParseArguments(const char* command)
std::vector<std::string> cmSystemTools::ParseArguments(const std::string& cmd)
{
std::vector<std::string> args;
std::string arg;
bool win_path = false;
const char* command = cmd.c_str();
if (command[0] && command[1] &&
((command[0] != '/' && command[1] == ':' && command[2] == '\\') ||
(command[0] == '\"' && command[1] != '/' && command[2] == ':' &&
......@@ -878,8 +879,7 @@ bool cmSystemTools::RunSingleCommand(const std::string& command,
outputflag = OUTPUT_NONE;
}
std::vector<std::string> args =
cmSystemTools::ParseArguments(command.c_str());
std::vector<std::string> args = cmSystemTools::ParseArguments(command);
if (args.empty()) {
return false;
......@@ -1411,7 +1411,7 @@ void cmSystemTools::ConvertToOutputSlashes(std::string& path)
#endif
}
std::string cmSystemTools::ConvertToRunCommandPath(const char* path)
std::string cmSystemTools::ConvertToRunCommandPath(const std::string& path)
{
#if defined(_WIN32) && !defined(__CYGWIN__)
return cmSystemTools::ConvertToWindowsOutputPath(path);
......@@ -1614,7 +1614,7 @@ void cmSystemTools::EnableVSConsoleOutput()
#endif
}
bool cmSystemTools::IsPathToFramework(const char* path)
bool cmSystemTools::IsPathToFramework(const std::string& path)
{
return (cmSystemTools::FileIsFullPath(path) &&
cmHasLiteralSuffix(path, ".framework"));
......@@ -3005,7 +3005,7 @@ bool cmSystemTools::CheckRPath(std::string const& file,
#endif
}
bool cmSystemTools::RepeatedRemoveDirectory(const char* dir)
bool cmSystemTools::RepeatedRemoveDirectory(const std::string& dir)
{
// Windows sometimes locks files temporarily so try a few times.
for (int i = 0; i < 10; ++i) {
......
......@@ -141,7 +141,7 @@ public:
///! Return true if value is NOTFOUND or ends in -NOTFOUND.
static bool IsNOTFOUND(const char* value);
///! Return true if the path is a framework
static bool IsPathToFramework(const char* value);
static bool IsPathToFramework(const std::string& value);
static bool DoesFileExistWithExtensions(
const std::string& name, const std::vector<std::string>& sourceExts);
......@@ -242,7 +242,7 @@ public:
/**
* Parse arguments out of a single string command
*/
static std::vector<std::string> ParseArguments(const char* command);
static std::vector<std::string> ParseArguments(const std::string& command);
/** Parse arguments out of a windows command line string. */
static void ParseWindowsCommandLine(const char* command,
......@@ -353,7 +353,7 @@ public:
// 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);
static std::string ConvertToRunCommandPath(const std::string& path);
/** compute the relative path from local to remote. local must
be a directory. remote can be a file or a directory.
......@@ -488,7 +488,7 @@ public:
static bool CheckRPath(std::string const& file, std::string const& newRPath);
/** Remove a directory; repeat a few times in case of locked files. */
static bool RepeatedRemoveDirectory(const char* dir);
static bool RepeatedRemoveDirectory(const std::string& dir);
/** Tokenize a string */
static std::vector<std::string> tokenize(const std::string& str,
......
......@@ -173,7 +173,7 @@ void cmTryRunCommand::RunExecutable(const std::string& runArgs,
std::vector<std::string> emulatorWithArgs;
cmSystemTools::ExpandListArgument(emulator, emulatorWithArgs);
finalCommand +=
cmSystemTools::ConvertToRunCommandPath(emulatorWithArgs[0].c_str());
cmSystemTools::ConvertToRunCommandPath(emulatorWithArgs[0]);
finalCommand += " ";
for (std::string const& arg : cmMakeRange(emulatorWithArgs).advance(1)) {
finalCommand += "\"";
......@@ -182,8 +182,7 @@ void cmTryRunCommand::RunExecutable(const std::string& runArgs,
finalCommand += " ";
}
}
finalCommand +=
cmSystemTools::ConvertToRunCommandPath(this->OutputFile.c_str());
finalCommand += cmSystemTools::ConvertToRunCommandPath(this->OutputFile);
if (!runArgs.empty()) {
finalCommand += runArgs;
}
......
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