summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2023-09-11 18:53:07 (GMT)
committerBrad King <brad.king@kitware.com>2023-09-12 19:04:15 (GMT)
commit0f16ebf333111920dcc3dd5748bb66c4f3995f07 (patch)
treee05bef134ef6572d22069d1c03d173ef3dc5727e
parent976659c8462e10ea545f1745b78f68bac9014a61 (diff)
downloadCMake-0f16ebf333111920dcc3dd5748bb66c4f3995f07.zip
CMake-0f16ebf333111920dcc3dd5748bb66c4f3995f07.tar.gz
CMake-0f16ebf333111920dcc3dd5748bb66c4f3995f07.tar.bz2
cmNinjaTargetGenerator: Reduce lifetime of custom command list
Since commit 2583eff6fe (ninja: Factor out custom command order-only depends, 2014-03-10, v3.1.0-rc1~559^2) we can store the list of custom commands in a local variable rather than a member.
-rw-r--r--Source/cmNinjaTargetGenerator.cxx15
-rw-r--r--Source/cmNinjaTargetGenerator.h2
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;
};