浏览代码

Makefiles: Port to cmGeneratorTarget.

Stephen Kelly 10 年之前
父节点
当前提交
4bc65d76f1

+ 0 - 2
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<cmLocalCommonGenerator*>(gt->LocalGenerator))
   , GlobalGenerator(static_cast<cmGlobalCommonGenerator*>(

+ 0 - 2
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;

+ 6 - 7
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<std::string> 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<std::string>::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;
       }

+ 1 - 1
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"; }

+ 6 - 5
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);
 }
 
 //----------------------------------------------------------------------------

+ 7 - 6
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<std::string, ImplicitDependFileMap> {};
   struct ImplicitDependTargetMap:
     public std::map<std::string, ImplicitDependLanguageMap> {};
-  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<std::string>& files);
   void WriteTargetRequiresRule(std::ostream& ruleFileStream,
-                               cmTarget& target,
+                               cmGeneratorTarget* target,
                                const std::vector<std::string>& objects);
 
   void AppendRuleDepend(std::vector<std::string>& depends,

+ 9 - 7
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.

+ 11 - 8
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.

+ 2 - 3
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());
     }

+ 0 - 2
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:

+ 6 - 5
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);