summaryrefslogtreecommitdiff
path: root/Source/cmExecuteProcessCommand.cxx
diff options
context:
space:
mode:
authorDāvis Mosāns <davispuh@gmail.com>2016-11-01 20:29:17 +0200
committerDāvis Mosāns <davispuh@gmail.com>2016-11-14 21:21:20 +0200
commit595feb323479ce6e8f8e8a3a863f9286d9f7bd64 (patch)
tree26a12439994c3b2480b859d8b8eda20681cb2c98 /Source/cmExecuteProcessCommand.cxx
parent96103972ea1c478a2845fb68aee70a3395c148e0 (diff)
downloadcmake-595feb323479ce6e8f8e8a3a863f9286d9f7bd64.tar.gz
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`).
Diffstat (limited to 'Source/cmExecuteProcessCommand.cxx')
-rw-r--r--Source/cmExecuteProcessCommand.cxx23
1 files changed, 21 insertions, 2 deletions
diff --git a/Source/cmExecuteProcessCommand.cxx b/Source/cmExecuteProcessCommand.cxx
index c8a3a84846..1562223b9d 100644
--- a/Source/cmExecuteProcessCommand.cxx
+++ b/Source/cmExecuteProcessCommand.cxx
@@ -8,6 +8,7 @@
#include <stdio.h>
#include "cmMakefile.h"
+#include "cmProcessOutput.h"
#include "cmSystemTools.h"
class cmExecutionStatus;
@@ -222,25 +223,43 @@ bool cmExecuteProcessCommand::InitialPass(std::vector<std::string> const& args,
int length;
char* data;
int p;
+ cmProcessOutput processOutput;
+ std::string strdata;
while ((p = cmsysProcess_WaitForData(cp, &data, &length, CM_NULLPTR), p)) {
// Put the output in the right place.
if (p == cmsysProcess_Pipe_STDOUT && !output_quiet) {
if (output_variable.empty()) {
- cmSystemTools::Stdout(data, length);
+ processOutput.DecodeText(data, length, strdata, 1);
+ cmSystemTools::Stdout(strdata.c_str(), strdata.size());
} else {
cmExecuteProcessCommandAppend(tempOutput, data, length);
}
} else if (p == cmsysProcess_Pipe_STDERR && !error_quiet) {
if (error_variable.empty()) {
- cmSystemTools::Stderr(data, length);
+ processOutput.DecodeText(data, length, strdata, 2);
+ cmSystemTools::Stderr(strdata.c_str(), strdata.size());
} else {
cmExecuteProcessCommandAppend(tempError, data, length);
}
}
}
+ if (!output_quiet && output_variable.empty()) {
+ processOutput.DecodeText(std::string(), strdata, 1);
+ if (!strdata.empty()) {
+ cmSystemTools::Stdout(strdata.c_str(), strdata.size());
+ }
+ }
+ if (!error_quiet && error_variable.empty()) {
+ processOutput.DecodeText(std::string(), strdata, 2);
+ if (!strdata.empty()) {
+ cmSystemTools::Stderr(strdata.c_str(), strdata.size());
+ }
+ }
// All output has been read. Wait for the process to exit.
cmsysProcess_WaitForExit(cp, CM_NULLPTR);
+ processOutput.DecodeText(tempOutput, tempOutput);
+ processOutput.DecodeText(tempError, tempError);
// Fix the text in the output strings.
cmExecuteProcessCommandFixText(tempOutput, output_strip_trailing_whitespace);