From 19b7c22d020a3b1bf26065beb33b0f2f499cd1ad Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Fri, 4 Apr 2014 17:09:56 +0200 Subject: Ninja: Query custom commands once per target, not once per file. Computing the source files is now more expensive, so the Ninja generator became very slow with a large number of files. --- Source/cmNinjaTargetGenerator.cxx | 14 +++++++------- Source/cmNinjaTargetGenerator.h | 1 + 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 56155ef..cb6eb90 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -494,6 +494,9 @@ cmNinjaTargetGenerator { cmCustomCommand const* cc = (*si)->GetCustomCommand(); this->GetLocalGenerator()->AddCustomCommandTarget(cc, this->GetTarget()); + // Record the custom commands for this target. The container is used + // in WriteObjectBuildStatement when called in a loop below. + this->CustomCommands.push_back((*si)->GetCustomCommand()); } std::vector headerSources; this->GeneratorTarget->GetHeaderSources(headerSources, config); @@ -565,14 +568,11 @@ cmNinjaTargetGenerator } // Add order-only dependencies on custom command outputs. - std::vector customCommands; - std::string config = this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"); - this->GeneratorTarget->GetCustomCommands(customCommands, config); - for(std::vector::const_iterator - si = customCommands.begin(); - si != customCommands.end(); ++si) + for(std::vector::const_iterator + cci = this->CustomCommands.begin(); + cci != this->CustomCommands.end(); ++cci) { - cmCustomCommand const* cc = (*si)->GetCustomCommand(); + cmCustomCommand const* cc = *cci; cmCustomCommandGenerator ccg(*cc, this->GetConfigName(), this->GetMakefile()); const std::vector& ccoutputs = ccg.GetOutputs(); diff --git a/Source/cmNinjaTargetGenerator.h b/Source/cmNinjaTargetGenerator.h index 8669e6e..8073af2 100644 --- a/Source/cmNinjaTargetGenerator.h +++ b/Source/cmNinjaTargetGenerator.h @@ -153,6 +153,7 @@ private: cmLocalNinjaGenerator* LocalGenerator; /// List of object files for this target. cmNinjaDeps Objects; + std::vector CustomCommands; typedef std::map LanguageFlagMap; LanguageFlagMap LanguageFlags; -- cgit v0.12