diff options
author | Brad King <brad.king@kitware.com> | 2023-09-13 12:44:16 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2023-09-13 12:44:11 (GMT) |
commit | 7f5d5f6e5aa2ab4c7043756b607125154fe44666 (patch) | |
tree | 1a7f259291e87490d7ef16acdf52ed80a901bb20 /Source | |
parent | a8c50d6faf8cd91ad8a338b41b9140c687bc27ca (diff) | |
parent | 0f16ebf333111920dcc3dd5748bb66c4f3995f07 (diff) | |
download | CMake-7f5d5f6e5aa2ab4c7043756b607125154fe44666.zip CMake-7f5d5f6e5aa2ab4c7043756b607125154fe44666.tar.gz CMake-7f5d5f6e5aa2ab4c7043756b607125154fe44666.tar.bz2 |
Merge topic 'ninja-cc-local'
0f16ebf333 cmNinjaTargetGenerator: Reduce lifetime of custom command list
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !8800
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmNinjaTargetGenerator.cxx | 15 | ||||
-rw-r--r-- | Source/cmNinjaTargetGenerator.h | 2 |
2 files changed, 8 insertions, 9 deletions
diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 09f8495..6187543 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -49,6 +49,8 @@ #include "cmValue.h" #include "cmake.h" +class cmCustomCommand; + std::unique_ptr<cmNinjaTargetGenerator> cmNinjaTargetGenerator::New( cmGeneratorTarget* target) { @@ -972,16 +974,15 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatements( << cmState::GetTargetTypeName(this->GetGeneratorTarget()->GetType()) << " target " << this->GetTargetName() << "\n\n"; + std::vector<cmCustomCommand const*> customCommands; { - std::vector<cmSourceFile const*> customCommands; - this->GeneratorTarget->GetCustomCommands(customCommands, config); - for (cmSourceFile const* sf : customCommands) { + std::vector<cmSourceFile const*> customCommandSources; + this->GeneratorTarget->GetCustomCommands(customCommandSources, config); + for (cmSourceFile const* sf : customCommandSources) { cmCustomCommand const* cc = sf->GetCustomCommand(); this->GetLocalGenerator()->AddCustomCommandTarget( cc, this->GetGeneratorTarget()); - // Record the custom commands for this target. The container is used - // in WriteObjectBuildStatement when called in a loop below. - this->Configs[config].CustomCommands.push_back(cc); + customCommands.push_back(cc); } } { @@ -1028,7 +1029,7 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatements( cm::append(orderOnlyDeps, this->Configs[config].ExtraFiles); // Add order-only dependencies on custom command outputs. - for (cmCustomCommand const* cc : this->Configs[config].CustomCommands) { + for (cmCustomCommand const* cc : customCommands) { cmCustomCommandGenerator ccg(*cc, config, this->GetLocalGenerator()); const std::vector<std::string>& ccoutputs = ccg.GetOutputs(); const std::vector<std::string>& ccbyproducts = ccg.GetByproducts(); diff --git a/Source/cmNinjaTargetGenerator.h b/Source/cmNinjaTargetGenerator.h index 49e7018..d41d86e 100644 --- a/Source/cmNinjaTargetGenerator.h +++ b/Source/cmNinjaTargetGenerator.h @@ -19,7 +19,6 @@ #include "cmNinjaTypes.h" #include "cmOSXBundleGenerator.h" -class cmCustomCommand; class cmGeneratedFileStream; class cmGeneratorTarget; class cmLocalNinjaGenerator; @@ -251,7 +250,6 @@ private: mutable ImportedCxxModuleLookup ImportedCxxModules; // Swift Support Json::Value SwiftOutputMap; - std::vector<cmCustomCommand const*> CustomCommands; cmNinjaDeps ExtraFiles; std::unique_ptr<MacOSXContentGeneratorType> MacOSXContentGenerator; }; |