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.
This commit is contained in:
Ben Boeckel 2014-03-10 21:07:31 -04:00 committed by Ben Boeckel
parent 18e478a860
commit 2583eff6fe
1 changed files with 15 additions and 14 deletions

View File

@ -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<cmSourceFile const*> 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<cmCustomCommand const*>::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<std::string>& 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<cmCustomCommand const*>::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<std::string>& 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