diff options
author | Ben McMorran <bemcmorr@microsoft.com> | 2020-08-01 00:37:26 (GMT) |
---|---|---|
committer | Ben McMorran <bemcmorr@microsoft.com> | 2020-08-07 06:36:03 (GMT) |
commit | 37a279f8d11c0a8d9aefad770412108742ddaed7 (patch) | |
tree | 8ca9cee602d5f903f3b99c6d9b646460debf140c /Source/cmLocalNinjaGenerator.cxx | |
parent | 67599c7ada47f37da950ca276538076be90eabb9 (diff) | |
download | CMake-37a279f8d11c0a8d9aefad770412108742ddaed7.zip CMake-37a279f8d11c0a8d9aefad770412108742ddaed7.tar.gz CMake-37a279f8d11c0a8d9aefad770412108742ddaed7.tar.bz2 |
Ninja: Write msvc_deps_prefix as UTF-8 when console codepage is UTF-8
Diffstat (limited to 'Source/cmLocalNinjaGenerator.cxx')
-rw-r--r-- | Source/cmLocalNinjaGenerator.cxx | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index ef34953..eb841d9 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -84,8 +84,26 @@ void cmLocalNinjaGenerator::Generate() if (!showIncludesPrefix.empty()) { cmGlobalNinjaGenerator::WriteComment(this->GetRulesFileStream(), "localized /showIncludes string"); - this->GetRulesFileStream() - << "msvc_deps_prefix = " << showIncludesPrefix << "\n\n"; + this->GetRulesFileStream() << "msvc_deps_prefix = "; +#ifdef WIN32 + // Ninja uses the ANSI Windows APIs, so strings in the rules file + // typically need to be ANSI encoded. However, in this case the compiler + // is being invoked using the UTF-8 codepage so the /showIncludes prefix + // will be UTF-8 encoded on stdout. Ninja can't successfully compare this + // UTF-8 encoded prefix to the ANSI encoded msvc_deps_prefix if it + // contains any non-ASCII characters and dependency checking will fail. + // As a workaround, leave the msvc_deps_prefix UTF-8 encoded even though + // the rest of the file is ANSI encoded. + if (GetConsoleOutputCP() == CP_UTF8 && GetACP() != CP_UTF8) { + this->GetRulesFileStream().WriteRaw(showIncludesPrefix); + } else { + this->GetRulesFileStream() << showIncludesPrefix; + } +#else + // It's safe to use the standard encoding on other platforms. + this->GetRulesFileStream() << showIncludesPrefix; +#endif + this->GetRulesFileStream() << "\n\n"; } } |