Преглед изворни кода

cmGlobalGenerator: Virtualize the Compute step and override it.

Stephen Kelly пре 10 година
родитељ
комит
5edb335485

+ 1 - 1
Source/cmGlobalGenerator.h

@@ -86,7 +86,7 @@ public:
    */
   virtual void Configure();
 
-  bool Compute();
+  virtual bool Compute();
 
   enum TargetTypes {
     AllTargets,

+ 10 - 1
Source/cmGlobalVisualStudio10Generator.cxx

@@ -314,9 +314,18 @@ cmGlobalVisualStudio10Generator::CreateLocalGenerator(cmLocalGenerator* parent,
 }
 
 //----------------------------------------------------------------------------
-void cmGlobalVisualStudio10Generator::Generate()
+bool cmGlobalVisualStudio10Generator::Compute()
 {
+  if (!cmGlobalVisualStudio8Generator::Compute())
+    {
+    return false;
+    }
   this->LongestSource = LongestSourcePath();
+  return true;
+}
+
+void cmGlobalVisualStudio10Generator::Generate()
+{
   this->cmGlobalVisualStudio8Generator::Generate();
   if(this->LongestSource.Length > 0)
     {

+ 2 - 0
Source/cmGlobalVisualStudio10Generator.h

@@ -45,6 +45,8 @@ public:
     std::vector<std::string> const& makeOptions = std::vector<std::string>()
     );
 
+  virtual bool Compute();
+
   ///! create the correct local generator
   virtual cmLocalGenerator *CreateLocalGenerator(cmLocalGenerator* parent,
                                                  cmState::Snapshot snapshot);

+ 7 - 4
Source/cmGlobalVisualStudio8Generator.cxx

@@ -347,8 +347,13 @@ bool cmGlobalVisualStudio8Generator::AddCheckTarget()
 }
 
 //----------------------------------------------------------------------------
-void cmGlobalVisualStudio8Generator::Generate()
+bool cmGlobalVisualStudio8Generator::Compute()
 {
+  if (!cmGlobalVisualStudio7Generator::Compute())
+    {
+    return false;
+    }
+
   if(this->AddCheckTarget())
     {
     // All targets depend on the build-system check target.
@@ -362,9 +367,7 @@ void cmGlobalVisualStudio8Generator::Generate()
         }
       }
     }
-
-  // Now perform the main generation.
-  this->cmGlobalVisualStudio7Generator::Generate();
+  return true;
 }
 
 //----------------------------------------------------------------------------

+ 1 - 1
Source/cmGlobalVisualStudio8Generator.h

@@ -67,7 +67,7 @@ public:
     return !this->WindowsCEVersion.empty(); }
 
 protected:
-  virtual void Generate();
+  virtual bool Compute();
   virtual const char* GetIDEVersion() { return "8.0"; }
 
   virtual std::string FindDevEnvCommand();

+ 7 - 4
Source/cmGlobalVisualStudioGenerator.cxx

@@ -64,8 +64,13 @@ std::string cmGlobalVisualStudioGenerator::GetRegistryBase(
 }
 
 //----------------------------------------------------------------------------
-void cmGlobalVisualStudioGenerator::Generate()
+bool cmGlobalVisualStudioGenerator::Compute()
 {
+  if (!cmGlobalGenerator::Compute())
+    {
+    return false;
+    }
+
   // Add a special target that depends on ALL projects for easy build
   // of one configuration only.
   const char* no_working_dir = 0;
@@ -136,9 +141,7 @@ void cmGlobalVisualStudioGenerator::Generate()
       static_cast<cmLocalVisualStudioGenerator*>(*lgi);
     lg->AddCMakeListsRules();
     }
-
-  // Run all the local generators.
-  this->cmGlobalGenerator::Generate();
+  return true;
 }
 
 //----------------------------------------------------------------------------

+ 1 - 1
Source/cmGlobalVisualStudioGenerator.h

@@ -108,7 +108,7 @@ public:
     cmGeneratorTarget*, std::vector<cmCustomCommand>& commands,
     std::string const& configName);
 protected:
-  virtual void Generate();
+  virtual bool Compute();
 
   // Does this VS version link targets to each other if there are
   // dependencies in the SLN file?  This was done for VS versions

+ 12 - 1
Source/cmGlobalXCodeGenerator.cxx

@@ -378,8 +378,13 @@ cmGlobalXCodeGenerator::CreateLocalGenerator(cmLocalGenerator* parent,
 }
 
 //----------------------------------------------------------------------------
-void cmGlobalXCodeGenerator::Generate()
+bool cmGlobalXCodeGenerator::Compute()
 {
+  if (!cmGlobalGenerator::Compute())
+    {
+      return false;
+    }
+
   std::map<std::string, std::vector<cmLocalGenerator*> >::iterator it;
   // make sure extra targets are added before calling
   // the parent generate which will call trace depends
@@ -390,11 +395,17 @@ void cmGlobalXCodeGenerator::Generate()
     // add ALL_BUILD, INSTALL, etc
     this->AddExtraTargets(root, it->second);
     }
+  return true;
+}
+
+void cmGlobalXCodeGenerator::Generate()
+{
   this->cmGlobalGenerator::Generate();
   if(cmSystemTools::GetErrorOccuredFlag())
     {
     return;
     }
+  std::map<std::string, std::vector<cmLocalGenerator*> >::iterator it;
   for(it = this->ProjectMap.begin(); it!= this->ProjectMap.end(); ++it)
     {
     cmLocalGenerator* root = it->second[0];

+ 1 - 0
Source/cmGlobalXCodeGenerator.h

@@ -88,6 +88,7 @@ public:
   virtual bool SetGeneratorToolset(std::string const& ts, cmMakefile* mf);
   void AppendFlag(std::string& flags, std::string const& flag);
 protected:
+  virtual bool Compute();
   virtual void Generate();
 private:
   cmXCodeObject* CreateOrGetPBXGroup(cmTarget& cmtarget,