RunSingleCommand: Replace verbose boolean with enum
No behaviour change, this prepares for adding a flag to skip the merging of output streams.
This commit is contained in:
parent
4096066723
commit
856a9e499f
|
@ -33,7 +33,7 @@
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
cmCPackGenerator::cmCPackGenerator()
|
cmCPackGenerator::cmCPackGenerator()
|
||||||
{
|
{
|
||||||
this->GeneratorVerbose = false;
|
this->GeneratorVerbose = cmSystemTools::OUTPUT_NONE;
|
||||||
this->MakefileMap = 0;
|
this->MakefileMap = 0;
|
||||||
this->Logger = 0;
|
this->Logger = 0;
|
||||||
this->componentPackageMethod = ONE_PACKAGE_PER_GROUP;
|
this->componentPackageMethod = ONE_PACKAGE_PER_GROUP;
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
#define cmCPackGenerator_h
|
#define cmCPackGenerator_h
|
||||||
|
|
||||||
#include "cmObject.h"
|
#include "cmObject.h"
|
||||||
|
#include "cmSystemTools.h"
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
@ -57,7 +58,9 @@ public:
|
||||||
/**
|
/**
|
||||||
* If verbose then more information is printed out
|
* If verbose then more information is printed out
|
||||||
*/
|
*/
|
||||||
void SetVerbose(bool val) { this->GeneratorVerbose = val; }
|
void SetVerbose(bool val)
|
||||||
|
{ this->GeneratorVerbose = val ?
|
||||||
|
cmSystemTools::OUTPUT_MERGE : cmSystemTools::OUTPUT_NONE; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Do the actual whole package processing.
|
* Do the actual whole package processing.
|
||||||
|
@ -194,7 +197,7 @@ protected:
|
||||||
virtual cmCPackComponentGroup* GetComponentGroup(const char *projectName,
|
virtual cmCPackComponentGroup* GetComponentGroup(const char *projectName,
|
||||||
const char* name);
|
const char* name);
|
||||||
|
|
||||||
bool GeneratorVerbose;
|
cmSystemTools::OutputOption GeneratorVerbose;
|
||||||
std::string Name;
|
std::string Name;
|
||||||
|
|
||||||
std::string InstallPath;
|
std::string InstallPath;
|
||||||
|
|
|
@ -786,7 +786,8 @@ CreateComponentDescription(cmCPackComponent *component,
|
||||||
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(cmd.c_str(), &output, &retVal,
|
||||||
dirName.c_str(), false, 0);
|
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");
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
cmCTestGenericHandler::cmCTestGenericHandler()
|
cmCTestGenericHandler::cmCTestGenericHandler()
|
||||||
{
|
{
|
||||||
this->HandlerVerbose = false;
|
this->HandlerVerbose = cmSystemTools::OUTPUT_NONE;
|
||||||
this->CTest = 0;
|
this->CTest = 0;
|
||||||
this->SubmitIndex = 0;
|
this->SubmitIndex = 0;
|
||||||
this->AppendXML = false;
|
this->AppendXML = false;
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
#include "cmObject.h"
|
#include "cmObject.h"
|
||||||
#include "cmCTest.h"
|
#include "cmCTest.h"
|
||||||
|
#include "cmSystemTools.h" //OutputOption
|
||||||
|
|
||||||
class cmMakefile;
|
class cmMakefile;
|
||||||
class cmCTestCommand;
|
class cmCTestCommand;
|
||||||
|
@ -31,7 +32,9 @@ public:
|
||||||
/**
|
/**
|
||||||
* If verbose then more informaiton is printed out
|
* If verbose then more informaiton is printed out
|
||||||
*/
|
*/
|
||||||
void SetVerbose(bool val) { this->HandlerVerbose = val; }
|
void SetVerbose(bool val)
|
||||||
|
{ this->HandlerVerbose = val ?
|
||||||
|
cmSystemTools::OUTPUT_MERGE : cmSystemTools::OUTPUT_NONE; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Populate internals from CTest custom scripts
|
* Populate internals from CTest custom scripts
|
||||||
|
@ -91,7 +94,7 @@ protected:
|
||||||
bool StartLogFile(const char* name, cmGeneratedFileStream& xofs);
|
bool StartLogFile(const char* name, cmGeneratedFileStream& xofs);
|
||||||
|
|
||||||
bool AppendXML;
|
bool AppendXML;
|
||||||
bool HandlerVerbose;
|
cmSystemTools::OutputOption HandlerVerbose;
|
||||||
cmCTest *CTest;
|
cmCTest *CTest;
|
||||||
t_StringToString Options;
|
t_StringToString Options;
|
||||||
t_StringToString PersistentOptions;
|
t_StringToString PersistentOptions;
|
||||||
|
|
|
@ -1301,7 +1301,8 @@ int cmCTestTestHandler::ExecuteCommands(std::vector<cmStdString>& vec)
|
||||||
int retVal = 0;
|
int retVal = 0;
|
||||||
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Run command: " << *it
|
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Run command: " << *it
|
||||||
<< std::endl);
|
<< std::endl);
|
||||||
if ( !cmSystemTools::RunSingleCommand(it->c_str(), 0, &retVal, 0, true
|
if ( !cmSystemTools::RunSingleCommand(it->c_str(), 0, &retVal, 0,
|
||||||
|
cmSystemTools::OUTPUT_MERGE
|
||||||
/*this->Verbose*/) || retVal != 0 )
|
/*this->Verbose*/) || retVal != 0 )
|
||||||
{
|
{
|
||||||
cmCTestLog(this->CTest, ERROR_MESSAGE, "Problem running command: "
|
cmCTestLog(this->CTest, ERROR_MESSAGE, "Problem running command: "
|
||||||
|
|
|
@ -1136,7 +1136,7 @@ int cmGlobalGenerator::Build(
|
||||||
const char *config,
|
const char *config,
|
||||||
bool clean, bool fast,
|
bool clean, bool fast,
|
||||||
double timeout,
|
double timeout,
|
||||||
bool verbose,
|
cmSystemTools::OutputOption outputflag,
|
||||||
const char* extraOptions,
|
const char* extraOptions,
|
||||||
std::vector<std::string> const& nativeOptions)
|
std::vector<std::string> const& nativeOptions)
|
||||||
{
|
{
|
||||||
|
@ -1176,7 +1176,7 @@ int cmGlobalGenerator::Build(
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!cmSystemTools::RunSingleCommand(cleanCommand.c_str(), outputPtr,
|
if (!cmSystemTools::RunSingleCommand(cleanCommand.c_str(), outputPtr,
|
||||||
&retVal, 0, verbose, timeout))
|
&retVal, 0, outputflag, timeout))
|
||||||
{
|
{
|
||||||
cmSystemTools::SetRunCommandHideConsole(hideconsole);
|
cmSystemTools::SetRunCommandHideConsole(hideconsole);
|
||||||
cmSystemTools::Error("Generator: execution of make clean failed.");
|
cmSystemTools::Error("Generator: execution of make clean failed.");
|
||||||
|
@ -1217,7 +1217,7 @@ int cmGlobalGenerator::Build(
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!cmSystemTools::RunSingleCommand(command, outputPtr,
|
if (!cmSystemTools::RunSingleCommand(command, outputPtr,
|
||||||
&retVal, 0, verbose, timeout))
|
&retVal, 0, outputflag, timeout))
|
||||||
{
|
{
|
||||||
cmSystemTools::SetRunCommandHideConsole(hideconsole);
|
cmSystemTools::SetRunCommandHideConsole(hideconsole);
|
||||||
cmSystemTools::Error
|
cmSystemTools::Error
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
|
|
||||||
#include "cmTarget.h" // For cmTargets
|
#include "cmTarget.h" // For cmTargets
|
||||||
#include "cmTargetDepend.h" // For cmTargetDependSet
|
#include "cmTargetDepend.h" // For cmTargetDependSet
|
||||||
|
#include "cmSystemTools.h" // for cmSystemTools::OutputOption
|
||||||
class cmake;
|
class cmake;
|
||||||
class cmMakefile;
|
class cmMakefile;
|
||||||
class cmLocalGenerator;
|
class cmLocalGenerator;
|
||||||
|
@ -102,7 +102,8 @@ public:
|
||||||
std::string *output,
|
std::string *output,
|
||||||
const char *makeProgram, const char *config,
|
const char *makeProgram, const char *config,
|
||||||
bool clean, bool fast,
|
bool clean, bool fast,
|
||||||
double timeout, bool verbose=false,
|
double timeout,
|
||||||
|
cmSystemTools::OutputOption outputflag=cmSystemTools::OUTPUT_NONE,
|
||||||
const char* extraOptions = 0,
|
const char* extraOptions = 0,
|
||||||
std::vector<std::string> const& nativeOptions =
|
std::vector<std::string> const& nativeOptions =
|
||||||
std::vector<std::string>());
|
std::vector<std::string>());
|
||||||
|
|
|
@ -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, false);
|
&host, 0, 0, cmSystemTools::OUTPUT_NONE);
|
||||||
|
|
||||||
// got the hostname
|
// got the hostname
|
||||||
if (host.length())
|
if (host.length())
|
||||||
|
|
|
@ -577,7 +577,7 @@ std::vector<cmStdString> cmSystemTools::ParseArguments(const char* command)
|
||||||
bool cmSystemTools::RunSingleCommand(std::vector<cmStdString>const& command,
|
bool cmSystemTools::RunSingleCommand(std::vector<cmStdString>const& command,
|
||||||
std::string* output ,
|
std::string* output ,
|
||||||
int* retVal , const char* dir ,
|
int* retVal , const char* dir ,
|
||||||
bool verbose ,
|
OutputOption outputflag ,
|
||||||
double timeout )
|
double timeout )
|
||||||
{
|
{
|
||||||
std::vector<const char*> argv;
|
std::vector<const char*> argv;
|
||||||
|
@ -599,17 +599,19 @@ bool cmSystemTools::RunSingleCommand(std::vector<cmStdString>const& command,
|
||||||
{
|
{
|
||||||
cmsysProcess_SetOption(cp, cmsysProcess_Option_HideWindow, 1);
|
cmsysProcess_SetOption(cp, cmsysProcess_Option_HideWindow, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
cmsysProcess_SetTimeout(cp, timeout);
|
cmsysProcess_SetTimeout(cp, timeout);
|
||||||
cmsysProcess_Execute(cp);
|
cmsysProcess_Execute(cp);
|
||||||
|
|
||||||
std::vector<char> tempOutput;
|
std::vector<char> tempOutput;
|
||||||
char* data;
|
char* data;
|
||||||
int length;
|
int length;
|
||||||
if ( output || verbose )
|
int pipe;
|
||||||
|
if ( output || outputflag != OUTPUT_NONE )
|
||||||
{
|
{
|
||||||
while(cmsysProcess_WaitForData(cp, &data, &length, 0))
|
while((pipe = cmsysProcess_WaitForData(cp, &data, &length, 0)))
|
||||||
{
|
{
|
||||||
if(output || verbose)
|
if(output || 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
|
||||||
|
@ -626,7 +628,7 @@ bool cmSystemTools::RunSingleCommand(std::vector<cmStdString>const& command,
|
||||||
{
|
{
|
||||||
tempOutput.insert(tempOutput.end(), data, data+length);
|
tempOutput.insert(tempOutput.end(), data, data+length);
|
||||||
}
|
}
|
||||||
if(verbose)
|
if(outputflag != OUTPUT_NONE)
|
||||||
{
|
{
|
||||||
cmSystemTools::Stdout(data, length);
|
cmSystemTools::Stdout(data, length);
|
||||||
}
|
}
|
||||||
|
@ -657,7 +659,7 @@ bool cmSystemTools::RunSingleCommand(std::vector<cmStdString>const& command,
|
||||||
else if(cmsysProcess_GetState(cp) == cmsysProcess_State_Exception)
|
else if(cmsysProcess_GetState(cp) == cmsysProcess_State_Exception)
|
||||||
{
|
{
|
||||||
const char* exception_str = cmsysProcess_GetExceptionString(cp);
|
const char* exception_str = cmsysProcess_GetExceptionString(cp);
|
||||||
if ( verbose )
|
if ( outputflag != OUTPUT_NONE )
|
||||||
{
|
{
|
||||||
std::cerr << exception_str << std::endl;
|
std::cerr << exception_str << std::endl;
|
||||||
}
|
}
|
||||||
|
@ -670,7 +672,7 @@ bool cmSystemTools::RunSingleCommand(std::vector<cmStdString>const& command,
|
||||||
else if(cmsysProcess_GetState(cp) == cmsysProcess_State_Error)
|
else if(cmsysProcess_GetState(cp) == cmsysProcess_State_Error)
|
||||||
{
|
{
|
||||||
const char* error_str = cmsysProcess_GetErrorString(cp);
|
const char* error_str = cmsysProcess_GetErrorString(cp);
|
||||||
if ( verbose )
|
if ( outputflag != OUTPUT_NONE )
|
||||||
{
|
{
|
||||||
std::cerr << error_str << std::endl;
|
std::cerr << error_str << std::endl;
|
||||||
}
|
}
|
||||||
|
@ -683,7 +685,7 @@ bool cmSystemTools::RunSingleCommand(std::vector<cmStdString>const& command,
|
||||||
else if(cmsysProcess_GetState(cp) == cmsysProcess_State_Expired)
|
else if(cmsysProcess_GetState(cp) == cmsysProcess_State_Expired)
|
||||||
{
|
{
|
||||||
const char* error_str = "Process terminated due to timeout\n";
|
const char* error_str = "Process terminated due to timeout\n";
|
||||||
if ( verbose )
|
if ( outputflag != OUTPUT_NONE )
|
||||||
{
|
{
|
||||||
std::cerr << error_str << std::endl;
|
std::cerr << error_str << std::endl;
|
||||||
}
|
}
|
||||||
|
@ -703,12 +705,12 @@ bool cmSystemTools::RunSingleCommand(
|
||||||
std::string* output,
|
std::string* output,
|
||||||
int *retVal,
|
int *retVal,
|
||||||
const char* dir,
|
const char* dir,
|
||||||
bool verbose,
|
OutputOption outputflag,
|
||||||
double timeout)
|
double timeout)
|
||||||
{
|
{
|
||||||
if(s_DisableRunCommandOutput)
|
if(s_DisableRunCommandOutput)
|
||||||
{
|
{
|
||||||
verbose = false;
|
outputflag = OUTPUT_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<cmStdString> args = cmSystemTools::ParseArguments(command);
|
std::vector<cmStdString> args = cmSystemTools::ParseArguments(command);
|
||||||
|
@ -718,7 +720,7 @@ bool cmSystemTools::RunSingleCommand(
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return cmSystemTools::RunSingleCommand(args, output,retVal,
|
return cmSystemTools::RunSingleCommand(args, output,retVal,
|
||||||
dir, verbose, timeout);
|
dir, outputflag, timeout);
|
||||||
}
|
}
|
||||||
bool cmSystemTools::RunCommand(const char* command,
|
bool cmSystemTools::RunCommand(const char* command,
|
||||||
std::string& output,
|
std::string& output,
|
||||||
|
|
|
@ -191,11 +191,12 @@ public:
|
||||||
int &retVal, const char* directory = 0,
|
int &retVal, const char* directory = 0,
|
||||||
bool verbose = true, int timeout = 0);
|
bool verbose = true, int timeout = 0);
|
||||||
/**
|
/**
|
||||||
* Run a single executable command and put the stdout and stderr
|
* Run a single executable command
|
||||||
* in output.
|
|
||||||
*
|
*
|
||||||
* If verbose is false, no user-viewable output from the program
|
* Output is controlled with outputflag. If outputflag is OUTPUT_NONE, no
|
||||||
* being run will be generated.
|
* user-viewable output from the program being run will be generated.
|
||||||
|
* OUTPUT_MERGE is the legacy behaviour where stdout and stderr are merged
|
||||||
|
* into stdout.
|
||||||
*
|
*
|
||||||
* If timeout is specified, the command will be terminated after
|
* If timeout is specified, the command will be terminated after
|
||||||
* timeout expires. Timeout is specified in seconds.
|
* timeout expires. Timeout is specified in seconds.
|
||||||
|
@ -210,9 +211,14 @@ public:
|
||||||
* it into this function or it will not work. The command must be correctly
|
* it into this function or it will not work. The command must be correctly
|
||||||
* escaped for this to with spaces.
|
* escaped for this to with spaces.
|
||||||
*/
|
*/
|
||||||
|
enum OutputOption
|
||||||
|
{
|
||||||
|
OUTPUT_NONE = 0,
|
||||||
|
OUTPUT_MERGE
|
||||||
|
};
|
||||||
static bool RunSingleCommand(const char* command, std::string* output = 0,
|
static bool RunSingleCommand(const char* command, std::string* output = 0,
|
||||||
int* retVal = 0, const char* dir = 0,
|
int* retVal = 0, const char* dir = 0,
|
||||||
bool verbose = true,
|
OutputOption outputflag = OUTPUT_MERGE,
|
||||||
double timeout = 0.0);
|
double timeout = 0.0);
|
||||||
/**
|
/**
|
||||||
* In this version of RunSingleCommand, command[0] should be
|
* In this version of RunSingleCommand, command[0] should be
|
||||||
|
@ -222,7 +228,7 @@ public:
|
||||||
static bool RunSingleCommand(std::vector<cmStdString> const& command,
|
static bool RunSingleCommand(std::vector<cmStdString> const& command,
|
||||||
std::string* output = 0,
|
std::string* output = 0,
|
||||||
int* retVal = 0, const char* dir = 0,
|
int* retVal = 0, const char* dir = 0,
|
||||||
bool verbose = true,
|
OutputOption outputflag = OUTPUT_MERGE,
|
||||||
double timeout = 0.0);
|
double timeout = 0.0);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -194,7 +194,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, &retVal,
|
||||||
0, false, timeout);
|
0, cmSystemTools::OUTPUT_NONE, timeout);
|
||||||
// set the run var
|
// set the run var
|
||||||
char retChar[1000];
|
char retChar[1000];
|
||||||
if (worked)
|
if (worked)
|
||||||
|
|
|
@ -1297,7 +1297,7 @@ int cmake::ExecuteCMakeCommand(std::vector<std::string>& args)
|
||||||
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, &retval,
|
||||||
directory.c_str(), true, timeout) )
|
directory.c_str(), cmSystemTools::OUTPUT_MERGE, timeout) )
|
||||||
{
|
{
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
@ -3978,7 +3978,7 @@ bool cmake::RunCommand(const char* comment,
|
||||||
// use rc command to create .res file
|
// use rc command to create .res file
|
||||||
cmSystemTools::RunSingleCommand(command,
|
cmSystemTools::RunSingleCommand(command,
|
||||||
&output,
|
&output,
|
||||||
&retCode, 0, false);
|
&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
|
||||||
// returned an error code then print the output anyway as
|
// returned an error code then print the output anyway as
|
||||||
|
@ -4338,7 +4338,8 @@ int cmake::Build(const std::string& dir,
|
||||||
projName.c_str(), target.c_str(),
|
projName.c_str(), target.c_str(),
|
||||||
&output,
|
&output,
|
||||||
makeProgram.c_str(),
|
makeProgram.c_str(),
|
||||||
config.c_str(), clean, false, 0, true,
|
config.c_str(), clean, false, 0,
|
||||||
|
cmSystemTools::OUTPUT_MERGE,
|
||||||
0, nativeOptions);
|
0, nativeOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue