ninja: Factor out target-level order-only dependencies

This reduces ninja file output even more for projects with lots of
libraries with entangled transitive dependencies. ParaView goes from the
previous 58M to about 45M.
This commit is contained in:
Ben Boeckel 2014-03-10 18:48:46 -04:00
parent 6fa6bedf78
commit 18e478a860
2 changed files with 26 additions and 5 deletions

View File

@ -121,6 +121,12 @@ void cmNinjaTargetGenerator::AddFeatureFlags(std::string& flags,
}
}
std::string
cmNinjaTargetGenerator::OrderDependsTargetForTarget()
{
return "cmake_order_depends_target_" + this->GetTargetName();
}
// TODO: Most of the code is picked up from
// void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink),
// void cmMakefileTargetGenerator::WriteTargetLanguageFlags()
@ -516,6 +522,19 @@ cmNinjaTargetGenerator
{
this->Objects.push_back(this->GetSourceFilePath(*si));
}
cmNinjaDeps orderOnlyDeps;
this->GetLocalGenerator()->AppendTargetDepends(this->Target, orderOnlyDeps);
cmNinjaDeps orderOnlyTarget;
orderOnlyTarget.push_back(this->OrderDependsTargetForTarget());
this->GetGlobalGenerator()->WritePhonyBuild(this->GetBuildFileStream(),
"Order-only phony target for "
+ this->GetTargetName(),
orderOnlyTarget,
cmNinjaDeps(),
cmNinjaDeps(),
orderOnlyDeps);
std::vector<cmSourceFile const*> objectSources;
this->GeneratorTarget->GetObjectSources(objectSources, config);
for(std::vector<cmSourceFile const*>::const_iterator
@ -554,11 +573,6 @@ cmNinjaTargetGenerator
sourceFileName = this->GetSourceFilePath(source);
explicitDeps.push_back(sourceFileName);
// Ensure that the target dependencies are built before any source file in
// the target, using order-only dependencies.
cmNinjaDeps orderOnlyDeps;
this->GetLocalGenerator()->AppendTargetDepends(this->Target, orderOnlyDeps);
cmNinjaDeps implicitDeps;
if(const char* objectDeps = source->GetProperty("OBJECT_DEPENDS")) {
std::vector<std::string> depList;
@ -567,6 +581,9 @@ cmNinjaTargetGenerator
std::back_inserter(implicitDeps), MapToNinjaPath());
}
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();

View File

@ -74,6 +74,10 @@ protected:
bool GetFeatureAsBool(const std::string& feature);
void AddFeatureFlags(std::string& flags, const std::string& lang);
std::string OrderDependsTargetForTarget();
std::string ComputeOrderDependsForTarget();
/**
* Compute the flags for compilation of object files for a given @a language.
* @note Generally it is the value of the variable whose name is computed