summaryrefslogtreecommitdiffstats
path: root/Source/cmMakefile.cxx
diff options
context:
space:
mode:
authorJustin Goshi <jgoshi@microsoft.com>2020-04-08 21:02:03 (GMT)
committerJustin Goshi <jgoshi@microsoft.com>2020-04-13 19:54:47 (GMT)
commitbc877a7e944d2a83867b4d55073fe3f83bcecc42 (patch)
tree2740d78f3d490b5791704df961fc9d43fab01e1e /Source/cmMakefile.cxx
parent37fa5122c2c1e2138b9e01191dc3cc1800f6ba40 (diff)
downloadCMake-bc877a7e944d2a83867b4d55073fe3f83bcecc42.zip
CMake-bc877a7e944d2a83867b4d55073fe3f83bcecc42.tar.gz
CMake-bc877a7e944d2a83867b4d55073fe3f83bcecc42.tar.bz2
Add support to indicate UTF-8 custom command pipe output encoding
Adds a flag to indicate that pipe output from a custom command should be interpreted as UTF-8 encoded. This change does not introduce a public way to set the flag, but generators that create internally-generated commands know if they are calling cmake, which uses UTF-8 pipes. MSBuild added support for interpreting output of PreBuildEvent, PreLinkEvent, PostBuildEvent, and CustomBuildStep as UTF-8. This change will appear in Visual Studio 16.6 Preview 3. It is opt-in, and you need to add the StdOutEncoding tag. MSBuild treats these as property bags so if we emit the tag for earlier versions of Visual Studio it would be safely ignored. This change emits the StdOutEncoding tag and sets it to UTF-8 whenever the custom command UTF-8 pipe flag is set. This fixes globalization issues when the output from cmake contained characters that required MSBuild to interpret as UTF-8 before displaying them.
Diffstat (limited to 'Source/cmMakefile.cxx')
-rw-r--r--Source/cmMakefile.cxx54
1 files changed, 28 insertions, 26 deletions
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 69f316d..498386c 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -1021,7 +1021,7 @@ cmTarget* cmMakefile::AddCustomCommandToTarget(
const cmCustomCommandLines& commandLines, cmCustomCommandType type,
const char* comment, const char* workingDir, bool escapeOldStyle,
bool uses_terminal, const std::string& depfile, const std::string& job_pool,
- bool command_expand_lists)
+ bool command_expand_lists, bool stdPipesUTF8)
{
cmTarget* t = this->GetCustomCommandTarget(
target, cmObjectLibraryCommands::Reject, this->Backtrace);
@@ -1039,14 +1039,15 @@ cmTarget* cmMakefile::AddCustomCommandToTarget(
cm::optional<std::string> workingStr = MakeOptionalString(workingDir);
// Dispatch command creation to allow generator expressions in outputs.
- this->AddGeneratorAction([=](cmLocalGenerator& lg,
- const cmListFileBacktrace& lfbt) {
- BacktraceGuard guard(this->Backtrace, lfbt);
- detail::AddCustomCommandToTarget(
- lg, lfbt, cmCommandOrigin::Project, t, byproducts, depends, commandLines,
- type, GetCStrOrNull(commentStr), GetCStrOrNull(workingStr),
- escapeOldStyle, uses_terminal, depfile, job_pool, command_expand_lists);
- });
+ this->AddGeneratorAction(
+ [=](cmLocalGenerator& lg, const cmListFileBacktrace& lfbt) {
+ BacktraceGuard guard(this->Backtrace, lfbt);
+ detail::AddCustomCommandToTarget(
+ lg, lfbt, cmCommandOrigin::Project, t, byproducts, depends,
+ commandLines, type, GetCStrOrNull(commentStr),
+ GetCStrOrNull(workingStr), escapeOldStyle, uses_terminal, depfile,
+ job_pool, command_expand_lists, stdPipesUTF8);
+ });
return t;
}
@@ -1057,14 +1058,14 @@ void cmMakefile::AddCustomCommandToOutput(
const char* comment, const char* workingDir,
const CommandSourceCallback& callback, bool replace, bool escapeOldStyle,
bool uses_terminal, bool command_expand_lists, const std::string& depfile,
- const std::string& job_pool)
+ const std::string& job_pool, bool stdPipesUTF8)
{
std::vector<std::string> no_byproducts;
cmImplicitDependsList no_implicit_depends;
this->AddCustomCommandToOutput(
{ output }, no_byproducts, depends, main_dependency, no_implicit_depends,
commandLines, comment, workingDir, callback, replace, escapeOldStyle,
- uses_terminal, command_expand_lists, depfile, job_pool);
+ uses_terminal, command_expand_lists, depfile, job_pool, stdPipesUTF8);
}
void cmMakefile::AddCustomCommandToOutput(
@@ -1075,7 +1076,7 @@ void cmMakefile::AddCustomCommandToOutput(
const cmCustomCommandLines& commandLines, const char* comment,
const char* workingDir, const CommandSourceCallback& callback, bool replace,
bool escapeOldStyle, bool uses_terminal, bool command_expand_lists,
- const std::string& depfile, const std::string& job_pool)
+ const std::string& depfile, const std::string& job_pool, bool stdPipesUTF8)
{
// Make sure there is at least one output.
if (outputs.empty()) {
@@ -1097,18 +1098,19 @@ void cmMakefile::AddCustomCommandToOutput(
cm::optional<std::string> workingStr = MakeOptionalString(workingDir);
// Dispatch command creation to allow generator expressions in outputs.
- this->AddGeneratorAction([=](cmLocalGenerator& lg,
- const cmListFileBacktrace& lfbt) {
- BacktraceGuard guard(this->Backtrace, lfbt);
- cmSourceFile* sf = detail::AddCustomCommandToOutput(
- lg, lfbt, cmCommandOrigin::Project, outputs, byproducts, depends,
- main_dependency, implicit_depends, commandLines,
- GetCStrOrNull(commentStr), GetCStrOrNull(workingStr), replace,
- escapeOldStyle, uses_terminal, command_expand_lists, depfile, job_pool);
- if (callback && sf) {
- callback(sf);
- }
- });
+ this->AddGeneratorAction(
+ [=](cmLocalGenerator& lg, const cmListFileBacktrace& lfbt) {
+ BacktraceGuard guard(this->Backtrace, lfbt);
+ cmSourceFile* sf = detail::AddCustomCommandToOutput(
+ lg, lfbt, cmCommandOrigin::Project, outputs, byproducts, depends,
+ main_dependency, implicit_depends, commandLines,
+ GetCStrOrNull(commentStr), GetCStrOrNull(workingStr), replace,
+ escapeOldStyle, uses_terminal, command_expand_lists, depfile, job_pool,
+ stdPipesUTF8);
+ if (callback && sf) {
+ callback(sf);
+ }
+ });
}
void cmMakefile::AddCustomCommandOldStyle(
@@ -1224,7 +1226,7 @@ cmTarget* cmMakefile::AddUtilityCommand(
const std::vector<std::string>& depends,
const cmCustomCommandLines& commandLines, bool escapeOldStyle,
const char* comment, bool uses_terminal, bool command_expand_lists,
- const std::string& job_pool)
+ const std::string& job_pool, bool stdPipesUTF8)
{
cmTarget* target = this->AddNewUtilityTarget(utilityName, excludeFromAll);
@@ -1253,7 +1255,7 @@ cmTarget* cmMakefile::AddUtilityCommand(
force, GetCStrOrNull(workingStr), byproducts,
depends, commandLines, escapeOldStyle,
GetCStrOrNull(commentStr), uses_terminal,
- command_expand_lists, job_pool);
+ command_expand_lists, job_pool, stdPipesUTF8);
});
return target;