mirror of
https://github.com/Kitware/CMake.git
synced 2026-02-22 06:59:01 -06:00
Windows: Encode child process output to internally-used encoding
Typically Windows applications (eg. MSVC compiler) use current console's codepage for output to pipes so we need to encode that to our internally-used encoding (`KWSYS_ENCODING_DEFAULT_CODEPAGE`).
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#include "cmMakefile.h"
|
||||
#include "cmProcessOutput.h"
|
||||
#include "cmSystemTools.h"
|
||||
|
||||
class cmExecutionStatus;
|
||||
@@ -214,17 +215,28 @@ bool cmExecProgramCommand::RunCommand(const char* command, std::string& output,
|
||||
int length;
|
||||
char* data;
|
||||
int p;
|
||||
cmProcessOutput processOutput;
|
||||
std::string strdata;
|
||||
while ((p = cmsysProcess_WaitForData(cp, &data, &length, CM_NULLPTR), p)) {
|
||||
if (p == cmsysProcess_Pipe_STDOUT || p == cmsysProcess_Pipe_STDERR) {
|
||||
if (verbose) {
|
||||
cmSystemTools::Stdout(data, length);
|
||||
processOutput.DecodeText(data, length, strdata);
|
||||
cmSystemTools::Stdout(strdata.c_str(), strdata.size());
|
||||
}
|
||||
output.append(data, length);
|
||||
}
|
||||
}
|
||||
|
||||
if (verbose) {
|
||||
processOutput.DecodeText(std::string(), strdata);
|
||||
if (!strdata.empty()) {
|
||||
cmSystemTools::Stdout(strdata.c_str(), strdata.size());
|
||||
}
|
||||
}
|
||||
|
||||
// All output has been read. Wait for the process to exit.
|
||||
cmsysProcess_WaitForExit(cp, CM_NULLPTR);
|
||||
processOutput.DecodeText(output, output);
|
||||
|
||||
// Check the result of running the process.
|
||||
std::string msg;
|
||||
|
||||
Reference in New Issue
Block a user