diff options
Diffstat (limited to 'Source')
| -rw-r--r-- | Source/cmGeneratedFileStream.cxx | 12 | ||||
| -rw-r--r-- | Source/cmGeneratedFileStream.h | 10 | ||||
| -rw-r--r-- | Source/cmGlobalXCodeGenerator.cxx | 29 | ||||
| -rw-r--r-- | Source/cmGlobalXCodeGenerator.h | 4 | ||||
| -rw-r--r-- | Source/cmLocalNinjaGenerator.cxx | 26 | ||||
| -rw-r--r-- | Source/cm_codecvt.cxx | 6 | ||||
| -rw-r--r-- | Source/cm_codecvt.hxx | 3 |
7 files changed, 48 insertions, 42 deletions
diff --git a/Source/cmGeneratedFileStream.cxx b/Source/cmGeneratedFileStream.cxx index 6212bbd..c72d6a7 100644 --- a/Source/cmGeneratedFileStream.cxx +++ b/Source/cmGeneratedFileStream.cxx @@ -14,11 +14,10 @@ #endif cmGeneratedFileStream::cmGeneratedFileStream(Encoding encoding) - : OriginalLocale(this->getloc()) { #ifndef CMAKE_BOOTSTRAP if (encoding != codecvt::None) { - this->imbue(std::locale(this->OriginalLocale, new codecvt(encoding))); + this->imbue(std::locale(this->getloc(), new codecvt(encoding))); } #else static_cast<void>(encoding); @@ -239,13 +238,16 @@ void cmGeneratedFileStream::SetTempExt(std::string const& ext) this->TempExt = ext; } -void cmGeneratedFileStream::WriteRaw(std::string const& data) +void cmGeneratedFileStream::WriteAltEncoding(std::string const& data, + Encoding encoding) { #ifndef CMAKE_BOOTSTRAP - std::locale activeLocale = this->imbue(this->OriginalLocale); + std::locale prevLocale = + this->imbue(std::locale(this->getloc(), new codecvt(encoding))); this->write(data.data(), data.size()); - this->imbue(activeLocale); + this->imbue(prevLocale); #else + static_cast<void>(encoding); this->write(data.data(), data.size()); #endif } diff --git a/Source/cmGeneratedFileStream.h b/Source/cmGeneratedFileStream.h index bb7e3bf..bfc121f 100644 --- a/Source/cmGeneratedFileStream.h +++ b/Source/cmGeneratedFileStream.h @@ -148,12 +148,8 @@ public: void SetTempExt(std::string const& ext); /** - * Writes the given string directly to the file without changing the - * encoding. + * Write a specific string using an alternate encoding. + * Afterward, the original encoding is restored. */ - void WriteRaw(std::string const& data); - -private: - // The original locale of the stream (performs no encoding conversion). - std::locale OriginalLocale; + void WriteAltEncoding(std::string const& data, Encoding encoding); }; diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index dd470f8..67b6e92 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -2544,8 +2544,8 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt, } if (gtgt->CanCompileSources()) { - std::string tmpDir = - cmStrCat(gtgt->GetSupportDirectory(), '/', this->GetCMakeCFGIntDir()); + std::string const tmpDir = + this->GetTargetTempDir(gtgt, this->GetCMakeCFGIntDir()); buildSettings->AddAttribute("TARGET_TEMP_DIR", this->CreateString(tmpDir)); std::string outDir; @@ -4399,7 +4399,7 @@ bool cmGlobalXCodeGenerator::CreateXCodeObjects( this->CreateString(swiftVersion)); } - std::string symroot = cmStrCat(root->GetCurrentBinaryDirectory(), "/build"); + std::string const symroot = this->GetSymrootDir(); buildSettings->AddAttribute("SYMROOT", this->CreateString(symroot)); // Inside a try_compile project, do not require signing on any platform. @@ -4498,6 +4498,19 @@ bool cmGlobalXCodeGenerator::CreateXCodeObjects( return true; } +std::string cmGlobalXCodeGenerator::GetSymrootDir() const +{ + return cmStrCat(this->CMakeInstance->GetHomeOutputDirectory(), "/build"); +} + +std::string cmGlobalXCodeGenerator::GetTargetTempDir( + cmGeneratorTarget const* gt, std::string const& configName) const +{ + // Use a path inside the SYMROOT. + return cmStrCat(this->GetSymrootDir(), '/', gt->GetName(), ".build/", + configName); +} + void cmGlobalXCodeGenerator::ComputeArchitectures(cmMakefile* mf) { this->Architectures.clear(); @@ -4621,8 +4634,8 @@ void cmGlobalXCodeGenerator::CreateXCodeDependHackMakefile( for (auto objLib : objlibs) { const std::string objLibName = objLib->GetName(); - std::string d = cmStrCat(objLib->GetSupportDirectory(), '/', - configName, "/lib", objLibName, ".a"); + std::string d = cmStrCat(this->GetTargetTempDir(gt, configName), + "/lib", objLibName, ".a"); std::string dependency = this->ConvertToRelativeForMake(d); makefileStream << "\\\n\t" << dependency; @@ -4636,8 +4649,8 @@ void cmGlobalXCodeGenerator::CreateXCodeDependHackMakefile( // if building for more than one architecture // then remove those executables as well if (this->Architectures.size() > 1) { - std::string universal = cmStrCat(gt->GetSupportDirectory(), '/', - configName, "/$(OBJDIR)/"); + std::string universal = + cmStrCat(this->GetTargetTempDir(gt, configName), "/$(OBJDIR)/"); for (const auto& architecture : this->Architectures) { std::string universalFile = cmStrCat(universal, architecture, '/', gt->GetFullName(configName)); @@ -5036,7 +5049,7 @@ void cmGlobalXCodeGenerator::ComputeTargetObjectDirectory( { auto objectDirArch = GetTargetObjectDirArch(*gt, this->ObjectDirArch); gt->ObjectDirectory = - cmStrCat(gt->GetSupportDirectory(), '/', this->GetCMakeCFGIntDir(), + cmStrCat(this->GetTargetTempDir(gt, this->GetCMakeCFGIntDir()), "/$(OBJECT_FILE_DIR_normal:base)/", objectDirArch, '/'); } diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h index e924169..9ae75fb 100644 --- a/Source/cmGlobalXCodeGenerator.h +++ b/Source/cmGlobalXCodeGenerator.h @@ -339,6 +339,10 @@ private: std::string GetLibraryOrFrameworkPath(const std::string& path) const; + std::string GetSymrootDir() const; + std::string GetTargetTempDir(cmGeneratorTarget const* gt, + std::string const& configName) const; + static std::string GetDeploymentPlatform(const cmMakefile* mf); void ComputeArchitectures(cmMakefile* mf); diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index 106f76b..c11f5b4 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -88,27 +88,11 @@ void cmLocalNinjaGenerator::Generate() cmGlobalNinjaGenerator::WriteComment(this->GetRulesFileStream(), "localized /showIncludes string"); 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->GetGlobalGenerator()->GetMakefileEncoding() != codecvt::None) { - this->GetRulesFileStream().WriteRaw(showIncludesPrefix); - } else { - // Ninja 1.11 and above uses the UTF-8 code page if it's supported, so - // in that case we can write it normally without using raw bytes. - this->GetRulesFileStream() << showIncludesPrefix; - } -#else - // It's safe to use the standard encoding on other platforms. - this->GetRulesFileStream() << showIncludesPrefix; -#endif + // 'cl /showIncludes' encodes output in the console output code page. + // It may differ from the encoding used for file paths in 'build.ninja'. + // Ninja matches the showIncludes prefix using its raw byte sequence. + this->GetRulesFileStream().WriteAltEncoding( + showIncludesPrefix, cmGeneratedFileStream::Encoding::ConsoleOutput); this->GetRulesFileStream() << "\n\n"; } } diff --git a/Source/cm_codecvt.cxx b/Source/cm_codecvt.cxx index 8115306..2d2a377 100644 --- a/Source/cm_codecvt.cxx +++ b/Source/cm_codecvt.cxx @@ -19,6 +19,12 @@ codecvt::codecvt(Encoding e) #endif { switch (e) { + case codecvt::ConsoleOutput: +#if defined(_WIN32) + m_noconv = false; + m_codepage = GetConsoleOutputCP(); + break; +#endif case codecvt::ANSI: #if defined(_WIN32) m_noconv = false; diff --git a/Source/cm_codecvt.hxx b/Source/cm_codecvt.hxx index 9af083f..f628de7 100644 --- a/Source/cm_codecvt.hxx +++ b/Source/cm_codecvt.hxx @@ -15,7 +15,8 @@ public: None, UTF8, UTF8_WITH_BOM, - ANSI + ANSI, + ConsoleOutput, }; #ifndef CMAKE_BOOTSTRAP |
