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