From 9f8afacb3e512debd1d53f14f685802eda4a54f8 Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 21 Jun 2024 09:28:51 -0400 Subject: cmGlobalNinjaGenerator: Reuse local generator caching of config list --- Source/cmGlobalCommonGenerator.cxx | 6 +++--- Source/cmGlobalNinjaGenerator.cxx | 10 +++++----- Source/cmGlobalNinjaGenerator.h | 2 +- Source/cmLocalNinjaGenerator.cxx | 7 ++----- Source/cmNinjaTargetGenerator.cxx | 3 +-- 5 files changed, 12 insertions(+), 16 deletions(-) diff --git a/Source/cmGlobalCommonGenerator.cxx b/Source/cmGlobalCommonGenerator.cxx index 513e3bf..b1b96d0 100644 --- a/Source/cmGlobalCommonGenerator.cxx +++ b/Source/cmGlobalCommonGenerator.cxx @@ -12,8 +12,8 @@ #include "cmGeneratorExpression.h" #include "cmGeneratorTarget.h" +#include "cmLocalCommonGenerator.h" #include "cmLocalGenerator.h" -#include "cmMakefile.h" #include "cmStateDirectory.h" #include "cmStateSnapshot.h" #include "cmStateTypes.h" @@ -38,8 +38,8 @@ cmGlobalCommonGenerator::ComputeDirectoryTargets() const lg->GetStateSnapshot().GetDirectory().GetCurrentBinary(); DirectoryTarget& dirTarget = dirTargets[currentBinaryDir]; dirTarget.LG = lg.get(); - const std::vector& configs = - lg->GetMakefile()->GetGeneratorConfigs(cmMakefile::IncludeEmptyConfig); + std::vector const& configs = + static_cast(lg.get())->GetConfigNames(); // The directory-level rule should depend on the target-level rules // for all targets in the directory. diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index c50ef00..96c8f25 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -603,10 +603,11 @@ cmDocumentationEntry cmGlobalNinjaGenerator::GetDocumentation() "Generates build.ninja files." }; } -std::vector cmGlobalNinjaGenerator::GetConfigNames() const +std::vector const& cmGlobalNinjaGenerator::GetConfigNames() const { - return this->Makefiles.front()->GetGeneratorConfigs( - cmMakefile::IncludeEmptyConfig); + return static_cast( + this->LocalGenerators.front().get()) + ->GetConfigNames(); } // Implemented in all cmGlobaleGenerator sub-classes. @@ -1632,8 +1633,7 @@ void cmGlobalNinjaGenerator::WriteFolderTargets(std::ostream& os) std::string const& currentBinaryDir = it.first; DirectoryTarget const& dt = it.second; std::vector configs = - dt.LG->GetMakefile()->GetGeneratorConfigs( - cmMakefile::IncludeEmptyConfig); + static_cast(dt.LG)->GetConfigNames(); // Setup target cmNinjaDeps configDeps; diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index 7c7b356..6ad38fb 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -485,7 +485,7 @@ public: bool CheckCxxModuleSupport(CxxModuleSupportQuery query) override; protected: - std::vector GetConfigNames() const; + std::vector const& GetConfigNames() const; void Generate() override; diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index bc3da6e..46a95af 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -743,8 +743,6 @@ void cmLocalNinjaGenerator::WriteCustomCommandBuildStatement( bool cmLocalNinjaGenerator::HasUniqueByproducts( std::vector const& byproducts, cmListFileBacktrace const& bt) { - std::vector configs = - this->GetMakefile()->GetGeneratorConfigs(cmMakefile::IncludeEmptyConfig); cmGeneratorExpression ge(*this->GetCMakeInstance(), bt); for (std::string const& p : byproducts) { if (cmGeneratorExpression::Find(p) == std::string::npos) { @@ -752,7 +750,7 @@ bool cmLocalNinjaGenerator::HasUniqueByproducts( } std::set seen; std::unique_ptr cge = ge.Parse(p); - for (std::string const& config : configs) { + for (std::string const& config : this->GetConfigNames()) { for (std::string const& b : this->ExpandCustomCommandOutputPaths(*cge, config)) { if (!seen.insert(b).second) { @@ -800,8 +798,7 @@ std::string cmLocalNinjaGenerator::CreateUtilityOutput( std::string const base = cmStrCat(this->GetCurrentBinaryDirectory(), "/CMakeFiles/", targetName, '-'); // The output is not actually created so mark it symbolic. - for (std::string const& config : - this->Makefile->GetGeneratorConfigs(cmMakefile::IncludeEmptyConfig)) { + for (std::string const& config : this->GetConfigNames()) { std::string const force = cmStrCat(base, config); if (cmSourceFile* sf = this->Makefile->GetOrCreateGeneratedSource(force)) { sf->SetProperty("SYMBOLIC", "1"); diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 160689c..a10635a 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -87,8 +87,7 @@ cmNinjaTargetGenerator::cmNinjaTargetGenerator(cmGeneratorTarget* target) , LocalGenerator( static_cast(target->GetLocalGenerator())) { - for (auto const& fileConfig : - target->Makefile->GetGeneratorConfigs(cmMakefile::IncludeEmptyConfig)) { + for (auto const& fileConfig : this->LocalGenerator->GetConfigNames()) { this->Configs[fileConfig].MacOSXContentGenerator = cm::make_unique(this, fileConfig); } -- cgit v0.12