From 07cfa57ec5f9f906e075512646100719a0a615aa Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 5 Nov 2010 08:33:47 -0400 Subject: Consolidate duplicate link rule make dependency code Factor code previously duplicated for library and executable rules into a common method. --- Source/cmMakefileExecutableTargetGenerator.cxx | 27 +--------------------- Source/cmMakefileLibraryTargetGenerator.cxx | 25 +-------------------- Source/cmMakefileTargetGenerator.cxx | 31 ++++++++++++++++++++++++++ Source/cmMakefileTargetGenerator.h | 3 +++ 4 files changed, 36 insertions(+), 50 deletions(-) diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index a5e319d..4426241 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -82,34 +82,9 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) { std::vector commands; - std::string relPath = this->LocalGenerator->GetHomeRelativeOutputPath(); - std::string objTarget; - // Build list of dependencies. std::vector depends; - for(std::vector::const_iterator obj = this->Objects.begin(); - obj != this->Objects.end(); ++obj) - { - objTarget = relPath; - objTarget += *obj; - depends.push_back(objTarget); - } - - // Add dependencies on targets that must be built first. - this->AppendTargetDepends(depends); - - // Add a dependency on the rule file itself. - this->LocalGenerator->AppendRuleDepend(depends, - this->BuildFileNameFull.c_str()); - - for(std::vector::const_iterator obj = - this->ExternalObjects.begin(); - obj != this->ExternalObjects.end(); ++obj) - { - depends.push_back(*obj); - } - - // from here up is the same for exe or lib + this->AppendLinkDepends(depends); // Get the name of the executable to generate. std::string targetName; diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index dff91fe..049a338 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -308,33 +308,10 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules // code duplication. std::vector commands; - std::string relPath = this->LocalGenerator->GetHomeRelativeOutputPath(); - std::string objTarget; - // Build list of dependencies. std::vector depends; - for(std::vector::const_iterator obj = this->Objects.begin(); - obj != this->Objects.end(); ++obj) - { - objTarget = relPath; - objTarget += *obj; - depends.push_back(objTarget); - } + this->AppendLinkDepends(depends); - // Add dependencies on targets that must be built first. - this->AppendTargetDepends(depends); - - // Add a dependency on the rule file itself. - this->LocalGenerator->AppendRuleDepend(depends, - this->BuildFileNameFull.c_str()); - - for(std::vector::const_iterator obj - = this->ExternalObjects.begin(); - obj != this->ExternalObjects.end(); ++obj) - { - depends.push_back(*obj); - } - // Get the language to use for linking this library. const char* linkLanguage = this->Target->GetLinkerLanguage(this->ConfigName); diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index d5d6585..0c150df 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -1507,6 +1507,37 @@ void cmMakefileTargetGenerator //---------------------------------------------------------------------------- void cmMakefileTargetGenerator +::AppendLinkDepends(std::vector& depends) +{ + // Add dependencies on the compiled object files. + std::string relPath = this->LocalGenerator->GetHomeRelativeOutputPath(); + std::string objTarget; + for(std::vector::const_iterator obj = this->Objects.begin(); + obj != this->Objects.end(); ++obj) + { + objTarget = relPath; + objTarget += *obj; + depends.push_back(objTarget); + } + + // Add dependencies on targets that must be built first. + this->AppendTargetDepends(depends); + + // Add a dependency on the rule file itself. + this->LocalGenerator->AppendRuleDepend(depends, + this->BuildFileNameFull.c_str()); + + // Add dependencies on the external object files. + for(std::vector::const_iterator obj + = this->ExternalObjects.begin(); + obj != this->ExternalObjects.end(); ++obj) + { + depends.push_back(*obj); + } +} + +//---------------------------------------------------------------------------- +void cmMakefileTargetGenerator ::CloseFileStreams() { delete this->BuildFileStream; diff --git a/Source/cmMakefileTargetGenerator.h b/Source/cmMakefileTargetGenerator.h index 4ee2b39..c9aede2 100644 --- a/Source/cmMakefileTargetGenerator.h +++ b/Source/cmMakefileTargetGenerator.h @@ -115,6 +115,9 @@ protected: // append intertarget dependencies void AppendTargetDepends(std::vector& depends); + // Append link rule dependencies (objects, etc.). + void AppendLinkDepends(std::vector& depends); + /** In order to support parallel builds for custom commands with multiple outputs the outputs are given a serial order, and only the first output actually has the build rule. Other outputs -- cgit v0.12