From 0ace6053e8a09656f2548697a8c61b9ad60a3cad Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Fri, 10 Feb 2023 17:52:17 -0500 Subject: Ninja: track modmap dependencies properly Mark modmaps as outputs of the collation step. --- Source/cmNinjaTargetGenerator.cxx | 27 ++++++++++++++++++++------- Source/cmNinjaTargetGenerator.h | 15 +++++++++++++-- 2 files changed, 33 insertions(+), 9 deletions(-) diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index da74fad..6f9bdbd 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -1140,13 +1140,20 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatements( } } - for (auto const& langDDIFiles : this->Configs[config].DDIFiles) { - std::string const& language = langDDIFiles.first; - cmNinjaDeps const& ddiFiles = langDDIFiles.second; + for (auto const& langScanningFiles : this->Configs[config].ScanningInfo) { + std::string const& language = langScanningFiles.first; + std::vector const& scanningFiles = langScanningFiles.second; cmNinjaBuild build(this->LanguageDyndepRule(language, config)); build.Outputs.push_back(this->GetDyndepFilePath(language, config)); - build.ExplicitDeps = ddiFiles; + for (auto const& scanFiles : scanningFiles) { + if (!scanFiles.ScanningOutput.empty()) { + build.ExplicitDeps.push_back(scanFiles.ScanningOutput); + } + if (!scanFiles.ModuleMapFile.empty()) { + build.ImplicitOuts.push_back(scanFiles.ModuleMapFile); + } + } this->WriteTargetDependInfo(language, config); @@ -1493,9 +1500,10 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatement( vars["INCLUDES"] = cmStrCat(sourceDirectoryFlag, ' ', vars["INCLUDES"]); } + ScanningFiles scanningFiles; + if (firstForConfig) { - std::string const ddiFile = cmStrCat(objectFileName, ".ddi"); - this->Configs[config].DDIFiles[language].push_back(ddiFile); + scanningFiles.ScanningOutput = cmStrCat(objectFileName, ".ddi"); } this->addPoolNinjaVariable("JOB_POOL_COMPILE", this->GetGeneratorTarget(), @@ -1512,9 +1520,14 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatement( // XXX(modmap): If changing this path construction, change // `cmGlobalNinjaGenerator::WriteDyndep` to expect the corresponding file // path. - std::string const ddModmapFile = cmStrCat(objectFileName, ".modmap"); + std::string ddModmapFile = cmStrCat(objectFileName, ".modmap"); vars["DYNDEP_MODULE_MAP_FILE"] = ddModmapFile; objBuild.OrderOnlyDeps.push_back(ddModmapFile); + scanningFiles.ModuleMapFile = std::move(ddModmapFile); + } + + if (!scanningFiles.IsEmpty()) { + this->Configs[config].ScanningInfo[language].emplace_back(scanningFiles); } } diff --git a/Source/cmNinjaTargetGenerator.h b/Source/cmNinjaTargetGenerator.h index 8bf7986..8f4a764 100644 --- a/Source/cmNinjaTargetGenerator.h +++ b/Source/cmNinjaTargetGenerator.h @@ -222,12 +222,23 @@ protected: private: cmLocalNinjaGenerator* LocalGenerator; + struct ScanningFiles + { + bool IsEmpty() const + { + return this->ScanningOutput.empty() && this->ModuleMapFile.empty(); + } + + std::string ScanningOutput; + std::string ModuleMapFile; + }; + struct ByConfig { /// List of object files for this target. cmNinjaDeps Objects; - // Fortran Support - std::map DDIFiles; + // Dyndep Support + std::map> ScanningInfo; // Swift Support Json::Value SwiftOutputMap; std::vector CustomCommands; -- cgit v0.12