Pārlūkot izejas kodu

C::B: Get the Makefile from the LocalGenerator, not vice-versa.

The Makefile is a configure-time concept, and the LocalGenerator
is a generate time concept.  The LocalGenerator should not be available
from the Makefile.
Stephen Kelly 10 gadi atpakaļ
vecāks
revīzija
2e9333a1d0

+ 13 - 11
Source/cmExtraCodeBlocksGenerator.cxx

@@ -313,7 +313,7 @@ void cmExtraCodeBlocksGenerator
         "      "<<virtualFolders<<"\n"
         "      <Build>\n";
 
-  this->AppendTarget(fout, "all", 0, make.c_str(), mf, compiler.c_str());
+  this->AppendTarget(fout, "all", 0, make.c_str(), lgs[0], compiler.c_str());
 
   // add all executable and library targets and some of the GLOBAL
   // and UTILITY targets
@@ -335,7 +335,7 @@ void cmExtraCodeBlocksGenerator
                      makefile->GetHomeOutputDirectory())==0)
             {
             this->AppendTarget(fout, ti->first, 0,
-                               make.c_str(), makefile, compiler.c_str());
+                               make.c_str(), *lg, compiler.c_str());
             }
           }
           break;
@@ -351,7 +351,7 @@ void cmExtraCodeBlocksGenerator
             }
 
           this->AppendTarget(fout, ti->first, 0,
-                                 make.c_str(), makefile, compiler.c_str());
+                                 make.c_str(), *lg, compiler.c_str());
           break;
         case cmTarget::EXECUTABLE:
         case cmTarget::STATIC_LIBRARY:
@@ -360,11 +360,11 @@ void cmExtraCodeBlocksGenerator
         case cmTarget::OBJECT_LIBRARY:
           {
           this->AppendTarget(fout, ti->first, &ti->second,
-                             make.c_str(), makefile, compiler.c_str());
+                             make.c_str(), *lg, compiler.c_str());
           std::string fastTarget = ti->first;
           fastTarget += "/fast";
           this->AppendTarget(fout, fastTarget, &ti->second,
-                             make.c_str(), makefile, compiler.c_str());
+                             make.c_str(), *lg, compiler.c_str());
           }
           break;
         default:
@@ -519,14 +519,16 @@ void cmExtraCodeBlocksGenerator
 
 // Write a dummy file for OBJECT libraries, so C::B can reference some file
 std::string cmExtraCodeBlocksGenerator::CreateDummyTargetFile(
-                                        cmMakefile* mf, cmTarget* target) const
+                                        cmLocalGenerator* lg,
+                                        cmTarget* target) const
 {
+  cmMakefile *mf = lg->GetMakefile();
   // this file doesn't seem to be used by C::B in custom makefile mode,
   // but we generate a unique file for each OBJECT library so in case
   // C::B uses it in some way, the targets don't interfere with each other.
   std::string filename = mf->GetCurrentBinaryDirectory();
   filename += "/";
-  filename += mf->GetLocalGenerator()->GetTargetDirectory(*target);
+  filename += lg->GetTargetDirectory(*target);
   filename += "/";
   filename += target->GetName();
   filename += ".objlib";
@@ -547,9 +549,10 @@ void cmExtraCodeBlocksGenerator::AppendTarget(cmGeneratedFileStream& fout,
                                               const std::string& targetName,
                                               cmTarget* target,
                                               const char* make,
-                                              const cmMakefile* makefile,
+                                              const cmLocalGenerator* lg,
                                               const char* compiler)
 {
+  cmMakefile const* makefile = lg->GetMakefile();
   std::string makefileName = makefile->GetCurrentBinaryDirectory();
   makefileName += "/Makefile";
 
@@ -583,7 +586,7 @@ void cmExtraCodeBlocksGenerator::AppendTarget(cmGeneratedFileStream& fout,
     std::string location;
     if ( target->GetType()==cmTarget::OBJECT_LIBRARY)
       {
-      location = this->CreateDummyTargetFile(const_cast<cmMakefile*>(makefile),
+      location = this->CreateDummyTargetFile(const_cast<cmLocalGenerator*>(lg),
                                              target);
       }
     else
@@ -618,8 +621,7 @@ void cmExtraCodeBlocksGenerator::AppendTarget(cmGeneratedFileStream& fout,
     std::set<std::string> uniqIncludeDirs;
 
     std::vector<std::string> includes;
-    target->GetMakefile()->GetLocalGenerator()->
-      GetIncludeDirectories(includes, gtgt, "C", buildType);
+    lg->GetIncludeDirectories(includes, gtgt, "C", buildType);
 
     uniqIncludeDirs.insert(includes.begin(), includes.end());
 

+ 3 - 2
Source/cmExtraCodeBlocksGenerator.h

@@ -48,7 +48,8 @@ private:
 
   void CreateNewProjectFile(const std::vector<cmLocalGenerator*>& lgs,
                                 const std::string& filename);
-  std::string CreateDummyTargetFile(cmMakefile* mf, cmTarget* target) const;
+  std::string CreateDummyTargetFile(cmLocalGenerator* lg,
+                                    cmTarget* target) const;
 
   std::string GetCBCompilerId(const cmMakefile* mf);
   int GetCBTargetType(cmTarget* target);
@@ -58,7 +59,7 @@ private:
                     const std::string& targetName,
                     cmTarget* target,
                     const char* make,
-                    const cmMakefile* makefile,
+                    const cmLocalGenerator* lg,
                     const char* compiler);
 
 };