diff options
-rw-r--r-- | Source/cmCxxModuleMapper.cxx | 14 | ||||
-rw-r--r-- | Source/cmCxxModuleMapper.h | 11 | ||||
-rw-r--r-- | Source/cmGlobalNinjaGenerator.cxx | 5 |
3 files changed, 29 insertions, 1 deletions
diff --git a/Source/cmCxxModuleMapper.cxx b/Source/cmCxxModuleMapper.cxx index b6b9540..4b2aec7 100644 --- a/Source/cmCxxModuleMapper.cxx +++ b/Source/cmCxxModuleMapper.cxx @@ -434,3 +434,17 @@ std::string CxxModuleMapContent(CxxModuleMapFormat format, assert(false); return {}; } + +CxxModuleMapMode CxxModuleMapOpenMode(CxxModuleMapFormat format) +{ + switch (format) { + case CxxModuleMapFormat::Gcc: + return CxxModuleMapMode::Binary; + case CxxModuleMapFormat::Clang: + case CxxModuleMapFormat::Msvc: + return CxxModuleMapMode::Default; + } + + assert(false); + return CxxModuleMapMode::Default; +} diff --git a/Source/cmCxxModuleMapper.h b/Source/cmCxxModuleMapper.h index c785099..898396c 100644 --- a/Source/cmCxxModuleMapper.h +++ b/Source/cmCxxModuleMapper.h @@ -83,6 +83,14 @@ struct CxxModuleUsage LookupMethod method); }; +enum class CxxModuleMapMode +{ + Text, + Binary, + + Default = Text, +}; + // Return the extension to use for a given modulemap format. cm::static_string_view CxxModuleMapExtension( cm::optional<CxxModuleMapFormat> format); @@ -101,3 +109,6 @@ std::string CxxModuleMapContent(CxxModuleMapFormat format, CxxModuleLocations const& loc, cmScanDepInfo const& obj, CxxModuleUsage const& usages); + +// Return the open mode required for the modmap file format. +CxxModuleMapMode CxxModuleMapOpenMode(CxxModuleMapFormat format); diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index f350efa..4ad801f 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -2783,7 +2783,10 @@ bool cmGlobalNinjaGenerator::WriteDyndepFile( // `cmNinjaTargetGenerator::WriteObjectBuildStatements` and // `cmNinjaTargetGenerator::ExportObjectCompileCommand` to generate the // corresponding file path. - cmGeneratedFileStream mmf(cmStrCat(object.PrimaryOutput, ".modmap")); + cmGeneratedFileStream mmf; + mmf.Open(cmStrCat(object.PrimaryOutput, ".modmap"), false, + CxxModuleMapOpenMode(*modmap_fmt) == + CxxModuleMapMode::Binary); mmf.SetCopyIfDifferent(true); mmf << mm; } |