diff options
author | Ben Boeckel <ben.boeckel@kitware.com> | 2014-03-10 18:48:46 -0400 |
---|---|---|
committer | Ben Boeckel <ben.boeckel@kitware.com> | 2014-05-07 14:30:31 -0400 |
commit | 18e478a860ce480f47ca2fdf583f3c5d65f93ccf (patch) | |
tree | af6cb645078d7d1a813d860219d29a22f2be76b7 | |
parent | 6fa6bedf78981d336b66d55ca10a1d290d014101 (diff) | |
download | cmake-18e478a860ce480f47ca2fdf583f3c5d65f93ccf.tar.gz |
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.
-rw-r--r-- | Source/cmNinjaTargetGenerator.cxx | 27 | ||||
-rw-r--r-- | Source/cmNinjaTargetGenerator.h | 4 |
2 files changed, 26 insertions, 5 deletions
diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index b95c4889d2..0b379bdd16 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -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(); diff --git a/Source/cmNinjaTargetGenerator.h b/Source/cmNinjaTargetGenerator.h index be516e07a1..94c420fb8c 100644 --- a/Source/cmNinjaTargetGenerator.h +++ b/Source/cmNinjaTargetGenerator.h @@ -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 |