From 4bc65d76f13c63367857b22e87f73baa8e6d5970 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 18 Oct 2015 23:20:47 +0200 Subject: [PATCH] Makefiles: Port to cmGeneratorTarget. --- Source/cmCommonTargetGenerator.cxx | 2 -- Source/cmCommonTargetGenerator.h | 2 -- Source/cmGlobalUnixMakefileGenerator3.cxx | 13 ++++++------- Source/cmGlobalUnixMakefileGenerator3.h | 2 +- Source/cmLocalUnixMakefileGenerator3.cxx | 11 ++++++----- Source/cmLocalUnixMakefileGenerator3.h | 13 +++++++------ .../cmMakefileExecutableTargetGenerator.cxx | 16 +++++++++------- Source/cmMakefileLibraryTargetGenerator.cxx | 19 +++++++++++-------- Source/cmMakefileTargetGenerator.cxx | 5 ++--- Source/cmMakefileTargetGenerator.h | 2 -- Source/cmMakefileUtilityTargetGenerator.cxx | 11 ++++++----- 11 files changed, 48 insertions(+), 48 deletions(-) diff --git a/Source/cmCommonTargetGenerator.cxx b/Source/cmCommonTargetGenerator.cxx index 2c47ab282..bd4771586 100644 --- a/Source/cmCommonTargetGenerator.cxx +++ b/Source/cmCommonTargetGenerator.cxx @@ -18,7 +18,6 @@ #include "cmMakefile.h" #include "cmSourceFile.h" #include "cmSystemTools.h" -#include "cmTarget.h" cmCommonTargetGenerator::cmCommonTargetGenerator( cmOutputConverter::RelativeRoot wd, @@ -26,7 +25,6 @@ cmCommonTargetGenerator::cmCommonTargetGenerator( ) : WorkingDirectory(wd) , GeneratorTarget(gt) - , Target(gt->Target) , Makefile(gt->Makefile) , LocalGenerator(static_cast(gt->LocalGenerator)) , GlobalGenerator(static_cast( diff --git a/Source/cmCommonTargetGenerator.h b/Source/cmCommonTargetGenerator.h index a4b2c10ec..3fb1fd093 100644 --- a/Source/cmCommonTargetGenerator.h +++ b/Source/cmCommonTargetGenerator.h @@ -21,7 +21,6 @@ class cmGlobalCommonGenerator; class cmLocalCommonGenerator; class cmMakefile; class cmSourceFile; -class cmTarget; /** \class cmCommonTargetGenerator * \brief Common infrastructure for Makefile and Ninja per-target generators @@ -49,7 +48,6 @@ protected: cmOutputConverter::RelativeRoot WorkingDirectory; cmGeneratorTarget* GeneratorTarget; - cmTarget* Target; cmMakefile* Makefile; cmLocalCommonGenerator* LocalGenerator; cmGlobalCommonGenerator* GlobalGenerator; diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index 4d7ca2577..b4a915c7f 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -16,7 +16,6 @@ #include "cmake.h" #include "cmGeneratedFileStream.h" #include "cmSourceFile.h" -#include "cmTarget.h" #include "cmGeneratorTarget.h" #include "cmAlgorithms.h" @@ -742,7 +741,7 @@ cmGlobalUnixMakefileGenerator3 makefileName = localName; makefileName += "/build.make"; - bool needRequiresStep = this->NeedRequiresStep(*gtarget->Target); + bool needRequiresStep = this->NeedRequiresStep(gtarget); lg->WriteDivider(ruleFileStream); ruleFileStream @@ -1129,19 +1128,19 @@ void cmGlobalUnixMakefileGenerator3::WriteHelpRule bool cmGlobalUnixMakefileGenerator3 -::NeedRequiresStep(cmTarget const& target) +::NeedRequiresStep(const cmGeneratorTarget* target) { std::set languages; - cmGeneratorTarget* gtgt = this->GetGeneratorTarget(&target); - gtgt->GetLanguages(languages, - target.GetMakefile()->GetSafeDefinition("CMAKE_BUILD_TYPE")); + target->GetLanguages(languages, + target->Target->GetMakefile() + ->GetSafeDefinition("CMAKE_BUILD_TYPE")); for(std::set::const_iterator l = languages.begin(); l != languages.end(); ++l) { std::string var = "CMAKE_NEEDS_REQUIRES_STEP_"; var += *l; var += "_FLAG"; - if(target.GetMakefile()->GetDefinition(var)) + if(target->Target->GetMakefile()->GetDefinition(var)) { return true; } diff --git a/Source/cmGlobalUnixMakefileGenerator3.h b/Source/cmGlobalUnixMakefileGenerator3.h index 0485eb885..63ffcb490 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.h +++ b/Source/cmGlobalUnixMakefileGenerator3.h @@ -154,7 +154,7 @@ protected: cmGeneratorTarget* target); // does this generator need a requires step for any of its targets - bool NeedRequiresStep(cmTarget const&); + bool NeedRequiresStep(cmGeneratorTarget const*); // Target name hooks for superclass. const char* GetAllTargetName() const { return "all"; } diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index e9dc9ff05..34a50a3f6 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -1977,7 +1977,7 @@ void cmLocalUnixMakefileGenerator3 cmGeneratorTarget* target) { ImplicitDependLanguageMap const& implicitLangs = - this->GetImplicitDepends(*target->Target); + this->GetImplicitDepends(target); // list the languages cmakefileStream @@ -2292,19 +2292,20 @@ cmLocalUnixMakefileGenerator3 //---------------------------------------------------------------------------- cmLocalUnixMakefileGenerator3::ImplicitDependLanguageMap const& -cmLocalUnixMakefileGenerator3::GetImplicitDepends(cmTarget const& tgt) +cmLocalUnixMakefileGenerator3::GetImplicitDepends( + const cmGeneratorTarget* tgt) { - return this->ImplicitDepends[tgt.GetName()]; + return this->ImplicitDepends[tgt->GetName()]; } //---------------------------------------------------------------------------- void -cmLocalUnixMakefileGenerator3::AddImplicitDepends(cmTarget const& tgt, +cmLocalUnixMakefileGenerator3::AddImplicitDepends(const cmGeneratorTarget* tgt, const std::string& lang, const char* obj, const char* src) { - this->ImplicitDepends[tgt.GetName()][lang][obj].push_back(src); + this->ImplicitDepends[tgt->GetName()][lang][obj].push_back(src); } //---------------------------------------------------------------------------- diff --git a/Source/cmLocalUnixMakefileGenerator3.h b/Source/cmLocalUnixMakefileGenerator3.h index 7e0f24813..8f6931170 100644 --- a/Source/cmLocalUnixMakefileGenerator3.h +++ b/Source/cmLocalUnixMakefileGenerator3.h @@ -21,7 +21,6 @@ class cmCustomCommand; class cmCustomCommandGenerator; class cmDepends; class cmMakefileTargetGenerator; -class cmTarget; class cmSourceFile; /** \class cmLocalUnixMakefileGenerator3 @@ -141,9 +140,11 @@ public: public std::map {}; struct ImplicitDependTargetMap: public std::map {}; - ImplicitDependLanguageMap const& GetImplicitDepends(cmTarget const& tgt); + ImplicitDependLanguageMap const& + GetImplicitDepends(cmGeneratorTarget const* tgt); - void AddImplicitDepends(cmTarget const& tgt, const std::string& lang, + void AddImplicitDepends(cmGeneratorTarget const* tgt, + const std::string& lang, const char* obj, const char* src); // write the target rules for the local Makefile into the stream @@ -197,12 +198,12 @@ protected: const std::string& helpTarget); void WriteTargetDependRule(std::ostream& ruleFileStream, - cmTarget& target); + cmGeneratorTarget* target); void WriteTargetCleanRule(std::ostream& ruleFileStream, - cmTarget& target, + cmGeneratorTarget* target, const std::vector& files); void WriteTargetRequiresRule(std::ostream& ruleFileStream, - cmTarget& target, + cmGeneratorTarget* target, const std::vector& objects); void AppendRuleDepend(std::vector& depends, diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index 020e64c54..f56037fdb 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -16,7 +16,6 @@ #include "cmLocalUnixMakefileGenerator3.h" #include "cmMakefile.h" #include "cmSourceFile.h" -#include "cmTarget.h" #include "cmake.h" //---------------------------------------------------------------------------- @@ -279,11 +278,13 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) if(!relink) { this->LocalGenerator - ->AppendCustomCommands(commands, this->Target->GetPreBuildCommands(), - this->GeneratorTarget); + ->AppendCustomCommands(commands, + this->GeneratorTarget->Target->GetPreBuildCommands(), + this->GeneratorTarget); this->LocalGenerator - ->AppendCustomCommands(commands, this->Target->GetPreLinkCommands(), - this->GeneratorTarget); + ->AppendCustomCommands(commands, + this->GeneratorTarget->Target->GetPreLinkCommands(), + this->GeneratorTarget); } // Determine whether a link script will be used. @@ -448,8 +449,9 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) if(!relink) { this->LocalGenerator-> - AppendCustomCommands(commands, this->Target->GetPostBuildCommands(), - this->GeneratorTarget); + AppendCustomCommands(commands, + this->GeneratorTarget->Target->GetPostBuildCommands(), + this->GeneratorTarget); } // Write the build rule. diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index df2a8c956..0a65641de 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -16,7 +16,6 @@ #include "cmLocalUnixMakefileGenerator3.h" #include "cmMakefile.h" #include "cmSourceFile.h" -#include "cmTarget.h" #include "cmake.h" #include "cmAlgorithms.h" @@ -114,7 +113,8 @@ void cmMakefileLibraryTargetGenerator::WriteObjectLibraryRules() // Add post-build rules. this->LocalGenerator-> - AppendCustomCommands(commands, this->Target->GetPostBuildCommands(), + AppendCustomCommands(commands, + this->GeneratorTarget->Target->GetPostBuildCommands(), this->GeneratorTarget); // Depend on the object files. @@ -457,11 +457,13 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules if(!relink) { this->LocalGenerator - ->AppendCustomCommands(commands, this->Target->GetPreBuildCommands(), - this->GeneratorTarget); + ->AppendCustomCommands(commands, + this->GeneratorTarget->Target->GetPreBuildCommands(), + this->GeneratorTarget); this->LocalGenerator - ->AppendCustomCommands(commands, this->Target->GetPreLinkCommands(), - this->GeneratorTarget); + ->AppendCustomCommands(commands, + this->GeneratorTarget->Target->GetPreLinkCommands(), + this->GeneratorTarget); } // Determine whether a link script will be used. @@ -811,8 +813,9 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules if(!relink) { this->LocalGenerator-> - AppendCustomCommands(commands, this->Target->GetPostBuildCommands(), - this->GeneratorTarget); + AppendCustomCommands(commands, + this->GeneratorTarget->Target->GetPostBuildCommands(), + this->GeneratorTarget); } // Compute the list of outputs. diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index b7970fdec..7acccb3e5 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -18,7 +18,6 @@ #include "cmLocalUnixMakefileGenerator3.h" #include "cmMakefile.h" #include "cmSourceFile.h" -#include "cmTarget.h" #include "cmake.h" #include "cmState.h" #include "cmComputeLinkInformation.h" @@ -432,7 +431,7 @@ void cmMakefileTargetGenerator std::string srcFullPath = this->Convert(source.GetFullPath(), cmLocalGenerator::FULL); this->LocalGenerator-> - AddImplicitDepends(*this->Target, lang, + AddImplicitDepends(this->GeneratorTarget, lang, objFullPath.c_str(), srcFullPath.c_str()); } @@ -1241,7 +1240,7 @@ void cmMakefileTargetGenerator std::string srcFullPath = this->Convert(idi->second, cmLocalGenerator::FULL); this->LocalGenerator-> - AddImplicitDepends(*this->Target, idi->first, + AddImplicitDepends(this->GeneratorTarget, idi->first, objFullPath.c_str(), srcFullPath.c_str()); } diff --git a/Source/cmMakefileTargetGenerator.h b/Source/cmMakefileTargetGenerator.h index e38c50b0a..38f40c082 100644 --- a/Source/cmMakefileTargetGenerator.h +++ b/Source/cmMakefileTargetGenerator.h @@ -24,7 +24,6 @@ class cmGeneratedFileStream; class cmGlobalUnixMakefileGenerator3; class cmLocalUnixMakefileGenerator3; class cmMakefile; -class cmTarget; class cmSourceFile; /** \class cmMakefileTargetGenerator @@ -51,7 +50,6 @@ public: std::string GetProgressFileNameFull() { return this->ProgressFileNameFull; } - cmTarget* GetTarget() { return this->Target;} cmGeneratorTarget* GetGeneratorTarget() { return this->GeneratorTarget;} protected: diff --git a/Source/cmMakefileUtilityTargetGenerator.cxx b/Source/cmMakefileUtilityTargetGenerator.cxx index 11601c5e4..d35c3ae03 100644 --- a/Source/cmMakefileUtilityTargetGenerator.cxx +++ b/Source/cmMakefileUtilityTargetGenerator.cxx @@ -16,7 +16,6 @@ #include "cmLocalUnixMakefileGenerator3.h" #include "cmMakefile.h" #include "cmSourceFile.h" -#include "cmTarget.h" //---------------------------------------------------------------------------- cmMakefileUtilityTargetGenerator @@ -68,19 +67,21 @@ void cmMakefileUtilityTargetGenerator::WriteRuleFiles() // Utility targets store their rules in pre- and post-build commands. this->LocalGenerator->AppendCustomDepends - (depends, this->Target->GetPreBuildCommands()); + (depends, this->GeneratorTarget->Target->GetPreBuildCommands()); this->LocalGenerator->AppendCustomDepends - (depends, this->Target->GetPostBuildCommands()); + (depends, this->GeneratorTarget->Target->GetPostBuildCommands()); this->LocalGenerator->AppendCustomCommands - (commands, this->Target->GetPreBuildCommands(), this->GeneratorTarget); + (commands, this->GeneratorTarget->Target->GetPreBuildCommands(), + this->GeneratorTarget); // Depend on all custom command outputs for sources this->DriveCustomCommands(depends); this->LocalGenerator->AppendCustomCommands - (commands, this->Target->GetPostBuildCommands(), this->GeneratorTarget); + (commands, this->GeneratorTarget->Target->GetPostBuildCommands(), + this->GeneratorTarget); // Add dependencies on targets that must be built first. this->AppendTargetDepends(depends);