mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-05 21:31:08 -06:00
Add Encoding option for RunChild, RunMakeCommand and RunProcess
This commit is contained in:
@@ -766,7 +766,7 @@ void cmCTestBuildHandler::LaunchHelper::WriteScrapeMatchers(
|
||||
|
||||
int cmCTestBuildHandler::RunMakeCommand(const char* command, int* retVal,
|
||||
const char* dir, int timeout,
|
||||
std::ostream& ofs)
|
||||
std::ostream& ofs, Encoding encoding)
|
||||
{
|
||||
// First generate the command and arguments
|
||||
std::vector<std::string> args = cmSystemTools::ParseArguments(command);
|
||||
@@ -810,7 +810,7 @@ int cmCTestBuildHandler::RunMakeCommand(const char* command, int* retVal,
|
||||
|
||||
char* data;
|
||||
int length;
|
||||
cmProcessOutput processOutput;
|
||||
cmProcessOutput processOutput(encoding);
|
||||
std::string strdata;
|
||||
cmCTestOptionalLog(
|
||||
this->CTest, HANDLER_PROGRESS_OUTPUT, " Each symbol represents "
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
#include "cmCTestGenericHandler.h"
|
||||
|
||||
#include <cmProcessOutput.h>
|
||||
#include <cmsys/RegularExpression.hxx>
|
||||
#include <deque>
|
||||
#include <iosfwd>
|
||||
@@ -25,6 +26,7 @@ class cmCTestBuildHandler : public cmCTestGenericHandler
|
||||
{
|
||||
public:
|
||||
typedef cmCTestGenericHandler Superclass;
|
||||
typedef cmProcessOutput::Encoding Encoding;
|
||||
|
||||
/*
|
||||
* The main entry point for this class
|
||||
@@ -49,7 +51,8 @@ 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 timeout, std::ostream& ofs);
|
||||
int timeout, std::ostream& ofs,
|
||||
Encoding encoding = cmProcessOutput::Auto);
|
||||
|
||||
enum
|
||||
{
|
||||
|
||||
@@ -76,7 +76,8 @@ bool cmCTestVC::InitialCheckout(const char* command)
|
||||
}
|
||||
|
||||
bool cmCTestVC::RunChild(char const* const* cmd, OutputParser* out,
|
||||
OutputParser* err, const char* workDir)
|
||||
OutputParser* err, const char* workDir,
|
||||
Encoding encoding)
|
||||
{
|
||||
this->Log << this->ComputeCommandLine(cmd) << "\n";
|
||||
|
||||
@@ -84,7 +85,7 @@ bool cmCTestVC::RunChild(char const* const* cmd, OutputParser* out,
|
||||
cmsysProcess_SetCommand(cp, cmd);
|
||||
workDir = workDir ? workDir : this->SourceDirectory.c_str();
|
||||
cmsysProcess_SetWorkingDirectory(cp, workDir);
|
||||
this->RunProcess(cp, out, err);
|
||||
this->RunProcess(cp, out, err, encoding);
|
||||
int result = cmsysProcess_GetExitValue(cp);
|
||||
cmsysProcess_Delete(cp);
|
||||
return result == 0;
|
||||
@@ -102,7 +103,7 @@ std::string cmCTestVC::ComputeCommandLine(char const* const* cmd)
|
||||
}
|
||||
|
||||
bool cmCTestVC::RunUpdateCommand(char const* const* cmd, OutputParser* out,
|
||||
OutputParser* err)
|
||||
OutputParser* err, Encoding encoding)
|
||||
{
|
||||
// Report the command line.
|
||||
this->UpdateCommandLine = this->ComputeCommandLine(cmd);
|
||||
@@ -112,7 +113,7 @@ bool cmCTestVC::RunUpdateCommand(char const* const* cmd, OutputParser* out,
|
||||
}
|
||||
|
||||
// Run the command.
|
||||
return this->RunChild(cmd, out, err);
|
||||
return this->RunChild(cmd, out, err, CM_NULLPTR, encoding);
|
||||
}
|
||||
|
||||
std::string cmCTestVC::GetNightlyTime()
|
||||
|
||||
@@ -116,11 +116,13 @@ protected:
|
||||
|
||||
/** Run a command line and send output to given parsers. */
|
||||
bool RunChild(char const* const* cmd, OutputParser* out, OutputParser* err,
|
||||
const char* workDir = CM_NULLPTR);
|
||||
const char* workDir = CM_NULLPTR,
|
||||
Encoding encoding = cmProcessOutput::Auto);
|
||||
|
||||
/** Run VC update command line and send output to given parsers. */
|
||||
bool RunUpdateCommand(char const* const* cmd, OutputParser* out,
|
||||
OutputParser* err = CM_NULLPTR);
|
||||
OutputParser* err = CM_NULLPTR,
|
||||
Encoding encoding = cmProcessOutput::Auto);
|
||||
|
||||
/** Write xml element for one file. */
|
||||
void WriteXMLEntry(cmXMLWriter& xml, std::string const& path,
|
||||
|
||||
@@ -961,7 +961,7 @@ int cmCTest::GetTestModelFromString(const char* str)
|
||||
|
||||
int cmCTest::RunMakeCommand(const char* command, std::string& output,
|
||||
int* retVal, const char* dir, int timeout,
|
||||
std::ostream& ofs)
|
||||
std::ostream& ofs, Encoding encoding)
|
||||
{
|
||||
// First generate the command and arguments
|
||||
std::vector<std::string> args = cmSystemTools::ParseArguments(command);
|
||||
@@ -1000,7 +1000,7 @@ int cmCTest::RunMakeCommand(const char* command, std::string& output,
|
||||
|
||||
char* data;
|
||||
int length;
|
||||
cmProcessOutput processOutput;
|
||||
cmProcessOutput processOutput(encoding);
|
||||
std::string strdata;
|
||||
cmCTestLog(this, HANDLER_PROGRESS_OUTPUT, " Each . represents "
|
||||
<< tick_len << " bytes of output" << std::endl
|
||||
@@ -1075,7 +1075,7 @@ int cmCTest::RunMakeCommand(const char* command, std::string& output,
|
||||
|
||||
int cmCTest::RunTest(std::vector<const char*> argv, std::string* output,
|
||||
int* retVal, std::ostream* log, double testTimeOut,
|
||||
std::vector<std::string>* environment)
|
||||
std::vector<std::string>* environment, Encoding encoding)
|
||||
{
|
||||
bool modifyEnv = (environment && !environment->empty());
|
||||
|
||||
@@ -1170,7 +1170,7 @@ int cmCTest::RunTest(std::vector<const char*> argv, std::string* output,
|
||||
|
||||
char* data;
|
||||
int length;
|
||||
cmProcessOutput processOutput;
|
||||
cmProcessOutput processOutput(encoding);
|
||||
std::string strdata;
|
||||
while (cmsysProcess_WaitForData(cp, &data, &length, CM_NULLPTR)) {
|
||||
processOutput.DecodeText(data, length, strdata);
|
||||
@@ -2523,7 +2523,7 @@ bool cmCTest::SetCTestConfigurationFromCMakeVariable(
|
||||
|
||||
bool cmCTest::RunCommand(const char* command, std::string* stdOut,
|
||||
std::string* stdErr, int* retVal, const char* dir,
|
||||
double timeout)
|
||||
double timeout, Encoding encoding)
|
||||
{
|
||||
std::vector<std::string> args = cmSystemTools::ParseArguments(command);
|
||||
|
||||
@@ -2554,7 +2554,7 @@ bool cmCTest::RunCommand(const char* command, std::string* stdOut,
|
||||
std::vector<char> tempError;
|
||||
char* data;
|
||||
int length;
|
||||
cmProcessOutput processOutput;
|
||||
cmProcessOutput processOutput(encoding);
|
||||
std::string strdata;
|
||||
int res;
|
||||
bool done = false;
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
#include <cmConfigure.h>
|
||||
|
||||
#include <cmProcessOutput.h>
|
||||
#include <cmsys/String.hxx>
|
||||
#include <map>
|
||||
#include <set>
|
||||
@@ -48,6 +49,7 @@ class cmCTest
|
||||
friend class cmCTestMultiProcessHandler;
|
||||
|
||||
public:
|
||||
typedef cmProcessOutput::Encoding Encoding;
|
||||
/** Enumerate parts of the testing and submission process. */
|
||||
enum Part
|
||||
{
|
||||
@@ -267,7 +269,8 @@ public:
|
||||
*/
|
||||
bool RunCommand(const char* command, std::string* stdOut,
|
||||
std::string* stdErr, int* retVal = CM_NULLPTR,
|
||||
const char* dir = CM_NULLPTR, double timeout = 0.0);
|
||||
const char* dir = CM_NULLPTR, double timeout = 0.0,
|
||||
Encoding encoding = cmProcessOutput::Auto);
|
||||
|
||||
/**
|
||||
* Clean/make safe for xml the given value such that it may be used as
|
||||
@@ -286,7 +289,8 @@ public:
|
||||
* and retVal is return value or exception.
|
||||
*/
|
||||
int RunMakeCommand(const char* command, std::string& output, int* retVal,
|
||||
const char* dir, int timeout, std::ostream& ofs);
|
||||
const char* dir, int timeout, std::ostream& ofs,
|
||||
Encoding encoding = cmProcessOutput::Auto);
|
||||
|
||||
/** Return the current tag */
|
||||
std::string GetCurrentTag();
|
||||
@@ -333,7 +337,8 @@ public:
|
||||
*/
|
||||
int RunTest(std::vector<const char*> args, std::string* output, int* retVal,
|
||||
std::ostream* logfile, double testTimeOut,
|
||||
std::vector<std::string>* environment);
|
||||
std::vector<std::string>* environment,
|
||||
Encoding encoding = cmProcessOutput::Auto);
|
||||
|
||||
/**
|
||||
* Execute handler and return its result. If the handler fails, it returns
|
||||
|
||||
@@ -117,7 +117,7 @@ bool cmExecProgramCommand::InitialPass(std::vector<std::string> const& args,
|
||||
|
||||
bool cmExecProgramCommand::RunCommand(const char* command, std::string& output,
|
||||
int& retVal, const char* dir,
|
||||
bool verbose)
|
||||
bool verbose, Encoding encoding)
|
||||
{
|
||||
if (cmSystemTools::GetRunCommandOutput()) {
|
||||
verbose = false;
|
||||
@@ -215,7 +215,7 @@ bool cmExecProgramCommand::RunCommand(const char* command, std::string& output,
|
||||
int length;
|
||||
char* data;
|
||||
int p;
|
||||
cmProcessOutput processOutput;
|
||||
cmProcessOutput processOutput(encoding);
|
||||
std::string strdata;
|
||||
while ((p = cmsysProcess_WaitForData(cp, &data, &length, CM_NULLPTR), p)) {
|
||||
if (p == cmsysProcess_Pipe_STDOUT || p == cmsysProcess_Pipe_STDERR) {
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include <vector>
|
||||
|
||||
#include "cmCommand.h"
|
||||
#include "cmProcessOutput.h"
|
||||
|
||||
class cmExecutionStatus;
|
||||
|
||||
@@ -21,6 +22,7 @@ class cmExecutionStatus;
|
||||
class cmExecProgramCommand : public cmCommand
|
||||
{
|
||||
public:
|
||||
typedef cmProcessOutput::Encoding Encoding;
|
||||
/**
|
||||
* This is a virtual constructor for the command.
|
||||
*/
|
||||
@@ -46,7 +48,8 @@ public:
|
||||
private:
|
||||
static bool RunCommand(const char* command, std::string& output, int& retVal,
|
||||
const char* directory = CM_NULLPTR,
|
||||
bool verbose = true);
|
||||
bool verbose = true,
|
||||
Encoding encoding = cmProcessOutput::Auto);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -7,13 +7,13 @@
|
||||
#include <ostream>
|
||||
|
||||
void cmProcessTools::RunProcess(struct cmsysProcess_s* cp, OutputParser* out,
|
||||
OutputParser* err)
|
||||
OutputParser* err, Encoding encoding)
|
||||
{
|
||||
cmsysProcess_Execute(cp);
|
||||
char* data = CM_NULLPTR;
|
||||
int length = 0;
|
||||
int p;
|
||||
cmProcessOutput processOutput;
|
||||
cmProcessOutput processOutput(encoding);
|
||||
std::string strdata;
|
||||
while ((out || err) &&
|
||||
(p = cmsysProcess_WaitForData(cp, &data, &length, CM_NULLPTR), p)) {
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#ifndef cmProcessTools_h
|
||||
#define cmProcessTools_h
|
||||
|
||||
#include "cmProcessOutput.h"
|
||||
#include <cmConfigure.h>
|
||||
|
||||
#include <iosfwd>
|
||||
@@ -16,6 +17,7 @@
|
||||
class cmProcessTools
|
||||
{
|
||||
public:
|
||||
typedef cmProcessOutput::Encoding Encoding;
|
||||
/** Abstract interface for process output parsers. */
|
||||
class OutputParser
|
||||
{
|
||||
@@ -79,7 +81,8 @@ public:
|
||||
|
||||
/** Run a process and send output to given parsers. */
|
||||
static void RunProcess(struct cmsysProcess_s* cp, OutputParser* out,
|
||||
OutputParser* err = CM_NULLPTR);
|
||||
OutputParser* err = CM_NULLPTR,
|
||||
Encoding encoding = cmProcessOutput::Auto);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -574,7 +574,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)
|
||||
double timeout, Encoding encoding)
|
||||
{
|
||||
std::vector<const char*> argv;
|
||||
for (std::vector<std::string>::const_iterator a = command.begin();
|
||||
@@ -610,7 +610,7 @@ bool cmSystemTools::RunSingleCommand(std::vector<std::string> const& command,
|
||||
char* data;
|
||||
int length;
|
||||
int pipe;
|
||||
cmProcessOutput processOutput;
|
||||
cmProcessOutput processOutput(encoding);
|
||||
std::string strdata;
|
||||
if (outputflag != OUTPUT_PASSTHROUGH &&
|
||||
(captureStdOut || captureStdErr || outputflag != OUTPUT_NONE)) {
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
#include <cmConfigure.h> // IWYU pragma: keep
|
||||
|
||||
#include <cmProcessOutput.h>
|
||||
#include <cmsys/Process.h>
|
||||
#include <cmsys/SystemTools.hxx>
|
||||
#include <stddef.h>
|
||||
@@ -29,6 +30,7 @@ class cmSystemTools : public cmsys::SystemTools
|
||||
{
|
||||
public:
|
||||
typedef cmsys::SystemTools Superclass;
|
||||
typedef cmProcessOutput::Encoding Encoding;
|
||||
|
||||
/** Expand out any arguments in the vector that have ; separated
|
||||
* strings into multiple arguments. A new vector is created
|
||||
@@ -239,7 +241,8 @@ public:
|
||||
int* retVal = CM_NULLPTR,
|
||||
const char* dir = CM_NULLPTR,
|
||||
OutputOption outputflag = OUTPUT_MERGE,
|
||||
double timeout = 0.0);
|
||||
double timeout = 0.0,
|
||||
Encoding encoding = cmProcessOutput::Auto);
|
||||
|
||||
static std::string PrintSingleCommand(std::vector<std::string> const&);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user