diff options
author | Dāvis Mosāns <davispuh@gmail.com> | 2016-11-01 18:29:17 (GMT) |
---|---|---|
committer | Dāvis Mosāns <davispuh@gmail.com> | 2016-11-14 19:21:20 (GMT) |
commit | 595feb323479ce6e8f8e8a3a863f9286d9f7bd64 (patch) | |
tree | 26a12439994c3b2480b859d8b8eda20681cb2c98 /Source/cmCTest.cxx | |
parent | 96103972ea1c478a2845fb68aee70a3395c148e0 (diff) | |
download | CMake-595feb323479ce6e8f8e8a3a863f9286d9f7bd64.zip CMake-595feb323479ce6e8f8e8a3a863f9286d9f7bd64.tar.gz CMake-595feb323479ce6e8f8e8a3a863f9286d9f7bd64.tar.bz2 |
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/cmCTest.cxx')
-rw-r--r-- | Source/cmCTest.cxx | 56 |
1 files changed, 47 insertions, 9 deletions
diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index f35a0b3..bf4507e 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -41,6 +41,7 @@ #include "cmGeneratedFileStream.h" #include "cmGlobalGenerator.h" #include "cmMakefile.h" +#include "cmProcessOutput.h" #include "cmState.h" #include "cmStateSnapshot.h" #include "cmStateTypes.h" @@ -999,16 +1000,19 @@ int cmCTest::RunMakeCommand(const char* command, std::string& output, char* data; int length; + cmProcessOutput processOutput; + std::string strdata; cmCTestLog(this, HANDLER_PROGRESS_OUTPUT, " Each . represents " << tick_len << " bytes of output" << std::endl << " " << std::flush); while (cmsysProcess_WaitForData(cp, &data, &length, CM_NULLPTR)) { - for (int cc = 0; cc < length; ++cc) { - if (data[cc] == 0) { - data[cc] = '\n'; + processOutput.DecodeText(data, length, strdata); + for (size_t cc = 0; cc < strdata.size(); ++cc) { + if (strdata[cc] == 0) { + strdata[cc] = '\n'; } } - output.append(data, length); + output.append(strdata); while (output.size() > (tick * tick_len)) { tick++; cmCTestLog(this, HANDLER_PROGRESS_OUTPUT, "." << std::flush); @@ -1019,9 +1023,19 @@ int cmCTest::RunMakeCommand(const char* command, std::string& output, << " " << std::flush); } } - cmCTestLog(this, HANDLER_VERBOSE_OUTPUT, cmCTestLogWrite(data, length)); + cmCTestLog(this, HANDLER_VERBOSE_OUTPUT, + cmCTestLogWrite(strdata.c_str(), strdata.size())); + if (ofs) { + ofs << cmCTestLogWrite(strdata.c_str(), strdata.size()); + } + } + processOutput.DecodeText(std::string(), strdata); + if (!strdata.empty()) { + output.append(strdata); + cmCTestLog(this, HANDLER_VERBOSE_OUTPUT, + cmCTestLogWrite(strdata.c_str(), strdata.size())); if (ofs) { - ofs << cmCTestLogWrite(data, length); + ofs << cmCTestLogWrite(strdata.c_str(), strdata.size()); } } cmCTestLog(this, HANDLER_PROGRESS_OUTPUT, " Size of output: " @@ -1156,17 +1170,30 @@ int cmCTest::RunTest(std::vector<const char*> argv, std::string* output, char* data; int length; + cmProcessOutput processOutput; + std::string strdata; while (cmsysProcess_WaitForData(cp, &data, &length, CM_NULLPTR)) { + processOutput.DecodeText(data, length, strdata); if (output) { tempOutput.insert(tempOutput.end(), data, data + length); } - cmCTestLog(this, HANDLER_VERBOSE_OUTPUT, cmCTestLogWrite(data, length)); + cmCTestLog(this, HANDLER_VERBOSE_OUTPUT, + cmCTestLogWrite(strdata.c_str(), strdata.size())); + if (log) { + log->write(strdata.c_str(), strdata.size()); + } + } + processOutput.DecodeText(std::string(), strdata); + if (!strdata.empty()) { + cmCTestLog(this, HANDLER_VERBOSE_OUTPUT, + cmCTestLogWrite(strdata.c_str(), strdata.size())); if (log) { - log->write(data, length); + log->write(strdata.c_str(), strdata.size()); } } cmsysProcess_WaitForExit(cp, CM_NULLPTR); + processOutput.DecodeText(tempOutput, tempOutput); if (output && tempOutput.begin() != tempOutput.end()) { output->append(&*tempOutput.begin(), tempOutput.size()); } @@ -2527,6 +2554,8 @@ bool cmCTest::RunCommand(const char* command, std::string* stdOut, std::vector<char> tempError; char* data; int length; + cmProcessOutput processOutput; + std::string strdata; int res; bool done = false; while (!done) { @@ -2543,15 +2572,24 @@ bool cmCTest::RunCommand(const char* command, std::string* stdOut, } if ((res == cmsysProcess_Pipe_STDOUT || res == cmsysProcess_Pipe_STDERR) && this->ExtraVerbose) { - cmSystemTools::Stdout(data, length); + processOutput.DecodeText(data, length, strdata); + cmSystemTools::Stdout(strdata.c_str(), strdata.size()); + } + } + if (this->ExtraVerbose) { + processOutput.DecodeText(std::string(), strdata); + if (!strdata.empty()) { + cmSystemTools::Stdout(strdata.c_str(), strdata.size()); } } cmsysProcess_WaitForExit(cp, CM_NULLPTR); if (!tempOutput.empty()) { + processOutput.DecodeText(tempOutput, tempOutput); stdOut->append(&*tempOutput.begin(), tempOutput.size()); } if (!tempError.empty()) { + processOutput.DecodeText(tempError, tempError); stdErr->append(&*tempError.begin(), tempError.size()); } |