Commit e6a80ccf authored by Wouter Klouwen's avatar Wouter Klouwen

Make use of std::chrono throughout every component

This commit continues the changes made in CTest to support std::chrono
by
applying it throughout every component where a duration was used.

No functional change intended.
parent ff62b005
......@@ -9,6 +9,7 @@
#include "cmCPackIFWPackage.h"
#include "cmCPackIFWRepository.h"
#include "cmCPackLog.h" // IWYU pragma: keep
#include "cmDuration.h"
#include "cmGeneratedFileStream.h"
#include "cmSystemTools.h"
......@@ -84,9 +85,9 @@ int cmCPackIFWGenerator::PackageFiles()
std::string output;
int retVal = 1;
cmCPackIFWLogger(OUTPUT, "- Generate repository" << std::endl);
bool res = cmSystemTools::RunSingleCommand(ifwCmd.c_str(), &output,
&output, &retVal, nullptr,
this->GeneratorVerbose, 0);
bool res = cmSystemTools::RunSingleCommand(
ifwCmd.c_str(), &output, &output, &retVal, nullptr,
this->GeneratorVerbose, cmDuration::zero());
if (!res || retVal) {
cmGeneratedFileStream ofs(ifwTmpFile.c_str());
ofs << "# Run command: " << ifwCmd << std::endl
......@@ -194,9 +195,9 @@ int cmCPackIFWGenerator::PackageFiles()
std::string output;
int retVal = 1;
cmCPackIFWLogger(OUTPUT, "- Generate package" << std::endl);
bool res = cmSystemTools::RunSingleCommand(ifwCmd.c_str(), &output,
&output, &retVal, nullptr,
this->GeneratorVerbose, 0);
bool res = cmSystemTools::RunSingleCommand(
ifwCmd.c_str(), &output, &output, &retVal, nullptr,
this->GeneratorVerbose, cmDuration::zero());
if (!res || retVal) {
cmGeneratedFileStream ofs(ifwTmpFile.c_str());
ofs << "# Run command: " << ifwCmd << std::endl
......
......@@ -4,6 +4,7 @@
#include "cmCPackGenerator.h"
#include "cmCPackLog.h"
#include "cmDuration.h"
#include "cmGeneratedFileStream.h"
#include "cmSystemTools.h"
......@@ -242,9 +243,9 @@ 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, 0);
bool result = cmSystemTools::RunSingleCommand(
command.str().c_str(), output, output, &exit_code, nullptr,
this->GeneratorVerbose, cmDuration::zero());
if (!result || exit_code) {
cmCPackLogger(cmCPackLog::LOG_ERROR, "Error executing: " << command.str()
......
......@@ -12,6 +12,7 @@
#include "cmCPackComponentGroup.h"
#include "cmCPackLog.h"
#include "cmCryptoHash.h"
#include "cmDuration.h"
#include "cmFSPermissions.h"
#include "cmGeneratedFileStream.h"
#include "cmGlobalGenerator.h"
......@@ -277,9 +278,9 @@ int cmCPackGenerator::InstallProjectViaInstallCommands(
cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Execute: " << ic << std::endl);
std::string output;
int retVal = 1;
bool resB =
cmSystemTools::RunSingleCommand(ic.c_str(), &output, &output, &retVal,
nullptr, this->GeneratorVerbose, 0);
bool resB = cmSystemTools::RunSingleCommand(
ic.c_str(), &output, &output, &retVal, nullptr, this->GeneratorVerbose,
cmDuration::zero());
if (!resB || retVal) {
std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
tmpFile += "/InstallOutput.log";
......@@ -601,7 +602,8 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects(
int retVal = 1;
bool resB = cmSystemTools::RunSingleCommand(
buildCommand.c_str(), &output, &output, &retVal,
installDirectory.c_str(), this->GeneratorVerbose, 0);
installDirectory.c_str(), this->GeneratorVerbose,
cmDuration::zero());
if (!resB || retVal) {
std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
tmpFile += "/PreinstallOutput.log";
......
......@@ -5,6 +5,7 @@
#include "cmCPackComponentGroup.h"
#include "cmCPackGenerator.h"
#include "cmCPackLog.h"
#include "cmDuration.h"
#include "cmGeneratedFileStream.h"
#include "cmSystemTools.h"
......@@ -301,9 +302,9 @@ int cmCPackNSISGenerator::PackageFiles()
cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Execute: " << nsisCmd << std::endl);
std::string output;
int retVal = 1;
bool res =
cmSystemTools::RunSingleCommand(nsisCmd.c_str(), &output, &output, &retVal,
nullptr, this->GeneratorVerbose, 0);
bool res = cmSystemTools::RunSingleCommand(
nsisCmd.c_str(), &output, &output, &retVal, nullptr,
this->GeneratorVerbose, cmDuration::zero());
if (!res || retVal) {
cmGeneratedFileStream ofs(tmpFile.c_str());
ofs << "# Run command: " << nsisCmd << std::endl
......@@ -400,9 +401,9 @@ int cmCPackNSISGenerator::InitializeInternal()
<< std::endl);
std::string output;
int retVal = 1;
bool resS =
cmSystemTools::RunSingleCommand(nsisCmd.c_str(), &output, &output, &retVal,
nullptr, this->GeneratorVerbose, 0);
bool resS = cmSystemTools::RunSingleCommand(
nsisCmd.c_str(), &output, &output, &retVal, nullptr,
this->GeneratorVerbose, cmDuration::zero());
cmsys::RegularExpression versionRex("v([0-9]+.[0-9]+)");
cmsys::RegularExpression versionRexCVS("v(.*)\\.cvs");
if (!resS || retVal ||
......@@ -737,9 +738,9 @@ std::string cmCPackNSISGenerator::CreateComponentDescription(
zipListFileName.c_str());
std::string output;
int retVal = -1;
int res = cmSystemTools::RunSingleCommand(cmd.c_str(), &output, &output,
&retVal, dirName.c_str(),
cmSystemTools::OUTPUT_NONE, 0);
int res = cmSystemTools::RunSingleCommand(
cmd.c_str(), &output, &output, &retVal, dirName.c_str(),
cmSystemTools::OUTPUT_NONE, cmDuration::zero());
if (!res || retVal) {
std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
tmpFile += "/CompressZip.log";
......
......@@ -6,6 +6,7 @@
#include "cmCPackGenerator.h"
#include "cmCPackLog.h"
#include "cmDuration.h"
#include "cmGeneratedFileStream.h"
#include "cmSystemTools.h"
#include "cm_sys_stat.h"
......@@ -154,9 +155,9 @@ int cmCPackOSXX11Generator::PackageFiles()
int numTries = 10;
bool res = false;
while (numTries > 0) {
res = cmSystemTools::RunSingleCommand(dmgCmd.str().c_str(), &output,
&output, &retVal, nullptr,
this->GeneratorVerbose, 0);
res = cmSystemTools::RunSingleCommand(
dmgCmd.str().c_str(), &output, &output, &retVal, nullptr,
this->GeneratorVerbose, cmDuration::zero());
if (res && !retVal) {
numTries = -1;
break;
......
......@@ -13,6 +13,7 @@
#include "cmCPackComponentGroup.h"
#include "cmCPackLog.h"
#include "cmDuration.h"
#include "cmGeneratedFileStream.h"
#include "cmSystemTools.h"
#include "cmXMLWriter.h"
......@@ -295,9 +296,9 @@ int cmCPackPackageMakerGenerator::PackageFiles()
int numTries = 10;
bool res = false;
while (numTries > 0) {
res = cmSystemTools::RunSingleCommand(dmgCmd.str().c_str(), &output,
&output, &retVal, nullptr,
this->GeneratorVerbose, 0);
res = cmSystemTools::RunSingleCommand(
dmgCmd.str().c_str(), &output, &output, &retVal, nullptr,
this->GeneratorVerbose, cmDuration::zero());
if (res && !retVal) {
numTries = -1;
break;
......@@ -467,7 +468,8 @@ bool cmCPackPackageMakerGenerator::RunPackageMaker(const char* command,
std::string output;
int retVal = 1;
bool res = cmSystemTools::RunSingleCommand(
command, &output, &output, &retVal, nullptr, this->GeneratorVerbose, 0);
command, &output, &output, &retVal, nullptr, this->GeneratorVerbose,
cmDuration::zero());
cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Done running package maker"
<< std::endl);
if (!res || retVal) {
......
......@@ -8,6 +8,7 @@
#include "cmCPackComponentGroup.h"
#include "cmCPackLog.h"
#include "cmDuration.h"
#include "cmGeneratedFileStream.h"
#include "cmSystemTools.h"
......@@ -145,9 +146,9 @@ bool cmCPackProductBuildGenerator::RunProductBuild(const std::string& command)
cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Execute: " << command << std::endl);
std::string output, error_output;
int retVal = 1;
bool res = cmSystemTools::RunSingleCommand(command.c_str(), &output,
&error_output, &retVal, nullptr,
this->GeneratorVerbose, 0);
bool res = cmSystemTools::RunSingleCommand(
command.c_str(), &output, &error_output, &retVal, nullptr,
this->GeneratorVerbose, cmDuration::zero());
cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Done running command" << std::endl);
if (!res || retVal) {
cmGeneratedFileStream ofs(tmpFile.c_str());
......
......@@ -251,7 +251,7 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring)
int retVal = cm.GetGlobalGenerator()->Build(
this->SourceDir, this->BinaryDir, this->BuildProject, tar, output,
this->BuildMakeProgram, config, !this->BuildNoClean, false, false,
remainingTime.count());
remainingTime);
out << output;
// if the build failed then return
if (retVal) {
......
......@@ -27,6 +27,7 @@
#include "cmCTestTestCommand.h"
#include "cmCTestUpdateCommand.h"
#include "cmCTestUploadCommand.h"
#include "cmDuration.h"
#include "cmFunctionBlocker.h"
#include "cmGeneratedFileStream.h"
#include "cmGlobalGenerator.h"
......@@ -206,7 +207,8 @@ int cmCTestScriptHandler::ExecuteScript(const std::string& total_script_arg)
std::vector<char> out;
std::vector<char> err;
std::string line;
int pipe = cmSystemTools::WaitForLine(cp, line, 100.0, out, err);
int pipe =
cmSystemTools::WaitForLine(cp, line, std::chrono::seconds(100), out, err);
while (pipe != cmsysProcess_Pipe_None) {
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Output: " << line
<< "\n");
......@@ -215,7 +217,8 @@ int cmCTestScriptHandler::ExecuteScript(const std::string& total_script_arg)
} else if (pipe == cmsysProcess_Pipe_STDOUT) {
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, line << "\n");
}
pipe = cmSystemTools::WaitForLine(cp, line, 100, out, err);
pipe = cmSystemTools::WaitForLine(cp, line, std::chrono::seconds(100), out,
err);
}
// Properly handle output of the build command
......@@ -601,7 +604,8 @@ int cmCTestScriptHandler::CheckOutSourceDir()
"Run cvs: " << this->CVSCheckOut << std::endl);
res = cmSystemTools::RunSingleCommand(
this->CVSCheckOut.c_str(), &output, &output, &retVal,
this->CTestRoot.c_str(), this->HandlerVerbose, 0 /*this->TimeOut*/);
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());
......@@ -668,7 +672,7 @@ int cmCTestScriptHandler::PerformExtraUpdates()
"Run Update: " << fullCommand << std::endl);
res = cmSystemTools::RunSingleCommand(
fullCommand.c_str(), &output, &output, &retVal, cvsArgs[0].c_str(),
this->HandlerVerbose, 0 /*this->TimeOut*/);
this->HandlerVerbose, cmDuration::zero() /*this->TimeOut*/);
if (!res || retVal != 0) {
cmSystemTools::Error("Unable to perform extra updates:\n", eu.c_str(),
"\nWith output:\n", output.c_str());
......@@ -772,7 +776,7 @@ int cmCTestScriptHandler::RunConfigurationDashboard()
"Run cmake command: " << command << std::endl);
res = cmSystemTools::RunSingleCommand(
command.c_str(), &output, &output, &retVal, this->BinaryDir.c_str(),
this->HandlerVerbose, 0 /*this->TimeOut*/);
this->HandlerVerbose, cmDuration::zero() /*this->TimeOut*/);
if (!this->CMOutFile.empty()) {
std::string cmakeOutputFile = this->CMOutFile;
......@@ -811,7 +815,7 @@ int cmCTestScriptHandler::RunConfigurationDashboard()
"Run ctest command: " << command << std::endl);
res = cmSystemTools::RunSingleCommand(
command.c_str(), &output, &output, &retVal, this->BinaryDir.c_str(),
this->HandlerVerbose, 0 /*this->TimeOut*/);
this->HandlerVerbose, cmDuration::zero() /*this->TimeOut*/);
// did something critical fail in ctest
if (!res || cmakeFailed || retVal & cmCTest::BUILD_ERRORS) {
......
......@@ -21,6 +21,7 @@
#include "cmComputeTargetDepends.h"
#include "cmCustomCommand.h"
#include "cmCustomCommandLines.h"
#include "cmDuration.h"
#include "cmExportBuildFileGenerator.h"
#include "cmExternalMakefileProjectGenerator.h"
#include "cmGeneratedFileStream.h"
......@@ -87,7 +88,7 @@ cmGlobalGenerator::cmGlobalGenerator(cmake* cm)
this->InstallTargetEnabled = false;
// how long to let try compiles run
this->TryCompileTimeout = 0;
this->TryCompileTimeout = cmDuration::zero();
this->ExtraGenerator = nullptr;
this->CurrentConfigureMakefile = nullptr;
......@@ -1801,7 +1802,7 @@ int cmGlobalGenerator::Build(const std::string& /*unused*/,
const std::string& target, std::string& output,
const std::string& makeCommandCSTR,
const std::string& config, bool clean, bool fast,
bool verbose, double timeout,
bool verbose, cmDuration timeout,
cmSystemTools::OutputOption outputflag,
std::vector<std::string> const& nativeOptions)
{
......
......@@ -14,6 +14,7 @@
#include <vector>
#include "cmCustomCommandLines.h"
#include "cmDuration.h"
#include "cmExportSetMap.h"
#include "cmStateSnapshot.h"
#include "cmSystemTools.h"
......@@ -160,8 +161,8 @@ public:
const std::string& projectName, const std::string& targetName,
std::string& output, const std::string& makeProgram,
const std::string& config, bool clean, bool fast, bool verbose,
double timeout, cmSystemTools::OutputOption outputflag =
cmSystemTools::OUTPUT_NONE,
cmDuration timeout, cmSystemTools::OutputOption outputflag =
cmSystemTools::OUTPUT_NONE,
std::vector<std::string> const& nativeOptions =
std::vector<std::string>());
......@@ -233,7 +234,7 @@ public:
void EnableInstallTarget();
int TryCompileTimeout;
cmDuration TryCompileTimeout;
bool GetForceUnixPaths() const { return this->ForceUnixPaths; }
bool GetToolSupportsColor() const { return this->ToolSupportsColor; }
......
......@@ -6,6 +6,7 @@
#include "cmAlgorithms.h"
#include "cmCustomCommand.h"
#include "cmCustomCommandLines.h"
#include "cmDuration.h"
#include "cmFilePathChecksum.h"
#include "cmGeneratorTarget.h"
#include "cmGlobalGenerator.h"
......@@ -410,7 +411,7 @@ void cmQtAutoGenInitializer::InitCustomTargets()
int retVal = 0;
bool result = cmSystemTools::RunSingleCommand(
command, &rccStdOut, &rccStdErr, &retVal, nullptr,
cmSystemTools::OUTPUT_NONE, 0.0, cmProcessOutput::Auto);
cmSystemTools::OUTPUT_NONE, cmDuration::zero(), cmProcessOutput::Auto);
if (result && retVal == 0 &&
rccStdOut.find("--list") != std::string::npos) {
this->RccListOptions.push_back("--list");
......@@ -1417,7 +1418,7 @@ bool cmQtAutoGenInitializer::RccListInputs(std::string const& fileName,
cmd.push_back(fileNameName);
result = cmSystemTools::RunSingleCommand(
cmd, &rccStdOut, &rccStdErr, &retVal, fileDir.c_str(),
cmSystemTools::OUTPUT_NONE, 0.0, cmProcessOutput::Auto);
cmSystemTools::OUTPUT_NONE, cmDuration::zero(), cmProcessOutput::Auto);
}
if (!result || retVal) {
error = "rcc list process failed for:\n ";
......
......@@ -3,6 +3,7 @@
#include "cmSystemTools.h"
#include "cmAlgorithms.h"
#include "cmDuration.h"
#include "cmProcessOutput.h"
#include "cm_sys_stat.h"
......@@ -699,7 +700,7 @@ bool cmSystemTools::RunSingleCommand(std::vector<std::string> const& command,
std::string* captureStdOut,
std::string* captureStdErr, int* retVal,
const char* dir, OutputOption outputflag,
double timeout, Encoding encoding)
cmDuration timeout, Encoding encoding)
{
std::vector<const char*> argv;
argv.reserve(command.size() + 1);
......@@ -727,7 +728,7 @@ bool cmSystemTools::RunSingleCommand(std::vector<std::string> const& command,
}
assert(!captureStdErr || captureStdErr != captureStdOut);
cmsysProcess_SetTimeout(cp, timeout);
cmsysProcess_SetTimeout(cp, timeout.count());
cmsysProcess_Execute(cp);
std::vector<char> tempStdOut;
......@@ -840,7 +841,7 @@ bool cmSystemTools::RunSingleCommand(const char* command,
std::string* captureStdOut,
std::string* captureStdErr, int* retVal,
const char* dir, OutputOption outputflag,
double timeout)
cmDuration timeout)
{
if (s_DisableRunCommandOutput) {
outputflag = OUTPUT_NONE;
......@@ -1811,7 +1812,7 @@ bool cmSystemTools::ListTar(const char* outFileName, bool verbose)
}
int cmSystemTools::WaitForLine(cmsysProcess* process, std::string& line,
double timeout, std::vector<char>& out,
cmDuration timeout, std::vector<char>& out,
std::vector<char>& err)
{
line.clear();
......@@ -1859,7 +1860,9 @@ int cmSystemTools::WaitForLine(cmsysProcess* process, std::string& line,
// No newlines found. Wait for more data from the process.
int length;
char* data;
int pipe = cmsysProcess_WaitForData(process, &data, &length, &timeout);
double timeoutAsDbl = timeout.count();
int pipe =
cmsysProcess_WaitForData(process, &data, &length, &timeoutAsDbl);
if (pipe == cmsysProcess_Pipe_Timeout) {
// Timeout has been exceeded.
return pipe;
......
......@@ -6,6 +6,7 @@
#include "cmConfigure.h" // IWYU pragma: keep
#include "cmCryptoHash.h"
#include "cmDuration.h"
#include "cmProcessOutput.h"
#include "cmsys/Process.h"
#include "cmsys/SystemTools.hxx" // IWYU pragma: export
......@@ -225,7 +226,7 @@ public:
int* retVal = nullptr,
const char* dir = nullptr,
OutputOption outputflag = OUTPUT_MERGE,
double timeout = 0.0);
cmDuration timeout = cmDuration::zero());
/**
* In this version of RunSingleCommand, command[0] should be
* the command to run, and each argument to the command should
......@@ -237,7 +238,7 @@ public:
int* retVal = nullptr,
const char* dir = nullptr,
OutputOption outputflag = OUTPUT_MERGE,
double timeout = 0.0,
cmDuration timeout = cmDuration::zero(),
Encoding encoding = cmProcessOutput::Auto);
static std::string PrintSingleCommand(std::vector<std::string> const&);
......@@ -343,7 +344,7 @@ public:
/** a general output handler for cmsysProcess */
static int WaitForLine(cmsysProcess* process, std::string& line,
double timeout, std::vector<char>& out,
cmDuration timeout, std::vector<char>& out,
std::vector<char>& err);
/** Split a string on its newlines into multiple lines. Returns
......
......@@ -5,6 +5,7 @@
#include "cmsys/FStream.hxx"
#include <stdio.h>
#include "cmDuration.h"
#include "cmMakefile.h"
#include "cmState.h"
#include "cmStateTypes.h"
......@@ -185,10 +186,9 @@ void cmTryRunCommand::RunExecutable(const std::string& runArgs,
if (!runArgs.empty()) {
finalCommand += runArgs;
}
int timeout = 0;
bool worked = cmSystemTools::RunSingleCommand(
finalCommand.c_str(), out, out, &retVal, nullptr,
cmSystemTools::OUTPUT_NONE, timeout);
cmSystemTools::OUTPUT_NONE, cmDuration::zero());
// set the run var
char retChar[16];
const char* retStr;
......
......@@ -7,6 +7,7 @@
#include "cmDocumentation.h"
#include "cmDocumentationEntry.h"
#include "cmDocumentationFormatter.h"
#include "cmDuration.h"
#include "cmExternalMakefileProjectGenerator.h"
#include "cmFileTimeComparison.h"
#include "cmGeneratorTarget.h"
......@@ -2475,8 +2476,8 @@ int cmake::Build(const std::string& dir, const std::string& target,
#endif
return gen->Build("", dir, projName, target, output, "", config, clean,
false, verbose, 0, cmSystemTools::OUTPUT_PASSTHROUGH,
nativeOptions);
false, verbose, cmDuration::zero(),
cmSystemTools::OUTPUT_PASSTHROUGH, nativeOptions);
}
bool cmake::Open(const std::string& dir, bool dryRun)
......
......@@ -8,6 +8,7 @@
#include <string>
#include <vector>
#include "cmDuration.h"
#include "cmSystemTools.h"
// This is a wrapper program for xcodebuild
......@@ -27,7 +28,8 @@ int RunXCode(std::vector<const char*>& argv, bool& hitbug)
std::vector<char> out;
std::vector<char> err;
std::string line;
int pipe = cmSystemTools::WaitForLine(cp, line, 100.0, out, err);
int pipe =
cmSystemTools::WaitForLine(cp, line, std::chrono::seconds(100), out, err);
while (pipe != cmsysProcess_Pipe_None) {
if (line.find("/bin/sh: bad interpreter: Text file busy") !=
std::string::npos) {
......@@ -45,7 +47,8 @@ int RunXCode(std::vector<const char*>& argv, bool& hitbug)
std::cout << line << "\n";
}
}
pipe = cmSystemTools::WaitForLine(cp, line, 100, out, err);
pipe = cmSystemTools::WaitForLine(cp, line, std::chrono::seconds(100), out,
err);
}
cmsysProcess_WaitForExit(cp, nullptr);
if (cmsysProcess_GetState(cp) == cmsysProcess_State_Exited) {
......
......@@ -3,6 +3,7 @@
#include "cmcmd.h"
#include "cmAlgorithms.h"
#include "cmDuration.h"
#include "cmGlobalGenerator.h"
#include "cmLocalGenerator.h"
#include "cmMakefile.h"
......@@ -797,10 +798,9 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
std::string command =
cmWrap('"', cmMakeRange(args).advance(3), '"', " ");
int retval = 0;
int timeout = 0;
if (cmSystemTools::RunSingleCommand(
command.c_str(), nullptr, nullptr, &retval, directory.c_str(),
cmSystemTools::OUTPUT_PASSTHROUGH, timeout)) {
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