From 2583eff6fe34f219a017c973c9e3bf12eb503178 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Mon, 10 Mar 2014 21:07:31 -0400 Subject: [PATCH] ninja: Factor out custom command order-only depends This makes WebKitGTK's CMake build.ninja file go from 165M to 11M and configure/generate in 5 seconds. --- Source/cmNinjaTargetGenerator.cxx | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 0b379bdd1..292a22f44 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -502,7 +502,7 @@ cmNinjaTargetGenerator 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()); + this->CustomCommands.push_back(cc); } std::vector headerSources; this->GeneratorTarget->GetHeaderSources(headerSources, config); @@ -525,6 +525,20 @@ cmNinjaTargetGenerator cmNinjaDeps orderOnlyDeps; this->GetLocalGenerator()->AppendTargetDepends(this->Target, orderOnlyDeps); + + // Add order-only dependencies on custom command outputs. + for(std::vector::const_iterator + cci = this->CustomCommands.begin(); + cci != this->CustomCommands.end(); ++cci) + { + cmCustomCommand const* cc = *cci; + cmCustomCommandGenerator ccg(*cc, this->GetConfigName(), + this->GetMakefile()); + const std::vector& ccoutputs = ccg.GetOutputs(); + std::transform(ccoutputs.begin(), ccoutputs.end(), + std::back_inserter(orderOnlyDeps), MapToNinjaPath()); + } + cmNinjaDeps orderOnlyTarget; orderOnlyTarget.push_back(this->OrderDependsTargetForTarget()); this->GetGlobalGenerator()->WritePhonyBuild(this->GetBuildFileStream(), @@ -584,19 +598,6 @@ cmNinjaTargetGenerator cmNinjaDeps orderOnlyDeps; orderOnlyDeps.push_back(this->OrderDependsTargetForTarget()); - // Add order-only dependencies on custom command outputs. - for(std::vector::const_iterator - cci = this->CustomCommands.begin(); - cci != this->CustomCommands.end(); ++cci) - { - cmCustomCommand const* cc = *cci; - cmCustomCommandGenerator ccg(*cc, this->GetConfigName(), - this->GetMakefile()); - const std::vector& ccoutputs = ccg.GetOutputs(); - std::transform(ccoutputs.begin(), ccoutputs.end(), - std::back_inserter(orderOnlyDeps), MapToNinjaPath()); - } - // If the source file is GENERATED and does not have a custom command // (either attached to this source file or another one), assume that one of // the target dependencies, OBJECT_DEPENDS or header file custom commands