[Cmake-commits] [cmake-commits] alex committed cmExtraEclipseCDT4Generator.h 1.10 1.11 cmExtraEclipseCDT4Generator.cxx 1.26 1.27 cmLocalUnixMakefileGenerator3.h 1.89 1.90 cmLocalUnixMakefileGenerator3.cxx 1.268 1.269

cmake-commits at cmake.org cmake-commits at cmake.org
Wed Sep 16 18:01:25 EDT 2009


Update of /cvsroot/CMake/CMake/Source
In directory public:/mounts/ram/cvs-serv25084

Modified Files:
	cmExtraEclipseCDT4Generator.h cmExtraEclipseCDT4Generator.cxx 
	cmLocalUnixMakefileGenerator3.h 
	cmLocalUnixMakefileGenerator3.cxx 
Log Message:
Major improvement of the generated targets in Eclipse.

Before this change all targets were displayed in the top level directory of
the project. Now the targets are displayed in the correct directory. 
The targets "clean" and "all" are now created in every subdirectory.
Also now the targets for just compiling one file, preprocessing one file,
assembling one file are are created for Eclipse.
Additionally all targets get a prefix now in eclipse, so that they are
sorted in a way which makes sense (global targets first, then executable and
libraries, then object files, then preprocessed, then assembly). Also
this prefix gives the user a hint what the target is, i.e. whether it's a
library or an executable or something else.

Alex


Index: cmLocalUnixMakefileGenerator3.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmLocalUnixMakefileGenerator3.h,v
retrieving revision 1.89
retrieving revision 1.90
diff -C 2 -d -r1.89 -r1.90
*** cmLocalUnixMakefileGenerator3.h	25 Jun 2009 13:58:51 -0000	1.89
--- cmLocalUnixMakefileGenerator3.h	16 Sep 2009 22:01:23 -0000	1.90
***************
*** 247,250 ****
--- 247,254 ----
    {
      bool HasSourceExtension;
+     bool HasPreprocessRule;
+     bool HasAssembleRule;
+     LocalObjectInfo():HasSourceExtension(false), HasPreprocessRule(false), 
+                       HasAssembleRule(false) {}
    };
    std::map<cmStdString, LocalObjectInfo> const& GetLocalObjectFiles()
***************
*** 267,270 ****
--- 271,280 ----
    void GetTargetObjectFileDirectories(cmTarget* target,
                                        std::vector<std::string>& dirs);
+ 
+   // Fill the vector with the target names for the object files, 
+   // preprocessed files and assembly files. Currently only used by the 
+   // Eclipse generator.
+   void GetIndividualFileTargets(std::vector<std::string>& targets);
+   
  protected:
    void WriteLocalMakefile();

Index: cmExtraEclipseCDT4Generator.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmExtraEclipseCDT4Generator.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -C 2 -d -r1.10 -r1.11
*** cmExtraEclipseCDT4Generator.h	10 Sep 2009 17:49:51 -0000	1.10
--- cmExtraEclipseCDT4Generator.h	16 Sep 2009 22:01:22 -0000	1.11
***************
*** 92,96 ****
    static void AppendTarget         (cmGeneratedFileStream& fout,
                                      const std::string&     target,
!                                     const std::string&     make);
    static void AppendScannerProfile (cmGeneratedFileStream& fout,
                                      const std::string&   profileID,
--- 92,98 ----
    static void AppendTarget         (cmGeneratedFileStream& fout,
                                      const std::string&     target,
!                                     const std::string&     make,
!                                     const std::string&     path,
!                                     const char* prefix = "");
    static void AppendScannerProfile (cmGeneratedFileStream& fout,
                                      const std::string&   profileID,

Index: cmLocalUnixMakefileGenerator3.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmLocalUnixMakefileGenerator3.cxx,v
retrieving revision 1.268
retrieving revision 1.269
diff -C 2 -d -r1.268 -r1.269
*** cmLocalUnixMakefileGenerator3.cxx	21 Jul 2009 15:58:43 -0000	1.268
--- cmLocalUnixMakefileGenerator3.cxx	16 Sep 2009 22:01:23 -0000	1.269
***************
*** 153,156 ****
--- 153,180 ----
  
  //----------------------------------------------------------------------------
+ void cmLocalUnixMakefileGenerator3::GetIndividualFileTargets
+                                             (std::vector<std::string>& targets)
+ {
+   for (std::map<cmStdString, LocalObjectInfo>::iterator lo = 
+          this->LocalObjectFiles.begin();
+        lo != this->LocalObjectFiles.end(); ++lo)
+     {
+     targets.push_back(lo->first);
+ 
+     std::string::size_type dot_pos = lo->first.rfind(".");
+     std::string base = lo->first.substr(0, dot_pos);
+     if(lo->second.HasPreprocessRule)
+       {
+       targets.push_back(base + ".i");
+       }
+ 
+     if(lo->second.HasAssembleRule)
+       {
+       targets.push_back(base + ".s");
+       }
+     }
+ }
+ 
+ //----------------------------------------------------------------------------
  void cmLocalUnixMakefileGenerator3::WriteLocalMakefile()
  {
***************
*** 229,232 ****
--- 253,257 ----
            ruleFileStream, "target to preprocess a source file",
            (base + ".i").c_str(), lo->second);
+           lo->second.HasPreprocessRule = true;
          }
        if(do_assembly_rules)
***************
*** 235,238 ****
--- 260,264 ----
            ruleFileStream, "target to generate assembly for a file",
            (base + ".s").c_str(), lo->second);
+           lo->second.HasAssembleRule = true;
          }
        }

Index: cmExtraEclipseCDT4Generator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmExtraEclipseCDT4Generator.cxx,v
retrieving revision 1.26
retrieving revision 1.27
diff -C 2 -d -r1.26 -r1.27
*** cmExtraEclipseCDT4Generator.cxx	16 Sep 2009 18:37:20 -0000	1.26
--- cmExtraEclipseCDT4Generator.cxx	16 Sep 2009 22:01:23 -0000	1.27
***************
*** 690,702 ****
    cmGlobalGenerator* generator
      = const_cast<cmGlobalGenerator*>(this->GlobalGenerator);
    if (generator->GetAllTargetName())
      {
!     emmited.insert(generator->GetAllTargetName());
!     this->AppendTarget(fout, generator->GetAllTargetName(), make);
      }
    if (generator->GetCleanTargetName())
      {
!     emmited.insert(generator->GetCleanTargetName());
!     this->AppendTarget(fout, generator->GetCleanTargetName(), make);
      }
  
--- 690,703 ----
    cmGlobalGenerator* generator
      = const_cast<cmGlobalGenerator*>(this->GlobalGenerator);
+   
+   std::string allTarget;
+   std::string cleanTarget;
    if (generator->GetAllTargetName())
      {
!     allTarget = generator->GetAllTargetName();
      }
    if (generator->GetCleanTargetName())
      {
!     cleanTarget = generator->GetCleanTargetName();
      }
  
***************
*** 710,713 ****
--- 711,721 ----
      const cmTargets& targets = (*it)->GetMakefile()->GetTargets();
      cmMakefile* makefile=(*it)->GetMakefile();
+     std::string subdir = (*it)->Convert(makefile->GetCurrentOutputDirectory(),
+                            cmLocalGenerator::HOME_OUTPUT);
+     if (subdir == ".")
+       {
+       subdir = "";
+       }
+ 
      for(cmTargets::const_iterator ti=targets.begin(); ti!=targets.end(); ++ti)
        {
***************
*** 719,724 ****
            // Only add the global targets from CMAKE_BINARY_DIR, 
            // not from the subdirs
!           if (strcmp(makefile->GetStartOutputDirectory(), 
!                      makefile->GetHomeOutputDirectory())==0)
             {
             insertTarget = true;
--- 727,731 ----
            // Only add the global targets from CMAKE_BINARY_DIR, 
            // not from the subdirs
!           if (subdir.empty())
             {
             insertTarget = true;
***************
*** 736,740 ****
           if (insertTarget)
             {
!            this->AppendTarget(fout, ti->first, make);
             }
           }
--- 743,747 ----
           if (insertTarget)
             {
!            this->AppendTarget(fout, ti->first, make, subdir, ": ");
             }
           }
***************
*** 751,755 ****
             }
  
!          this->AppendTarget(fout, ti->first, make);
           break;
         case cmTarget::EXECUTABLE:
--- 758,762 ----
             }
  
!          this->AppendTarget(fout, ti->first, make, subdir, ": ");
           break;
         case cmTarget::EXECUTABLE:
***************
*** 758,765 ****
         case cmTarget::MODULE_LIBRARY:
           {
!          this->AppendTarget(fout, ti->first, make);
           std::string fastTarget = ti->first;
           fastTarget += "/fast";
!          this->AppendTarget(fout, fastTarget, make);
           }
           break;
--- 765,774 ----
         case cmTarget::MODULE_LIBRARY:
           {
!          const char* prefix = (ti->second.GetType()==cmTarget::EXECUTABLE ?
!                                                           "[exe] " : "[lib] ");
!          this->AppendTarget(fout, ti->first, make, subdir, prefix);
           std::string fastTarget = ti->first;
           fastTarget += "/fast";
!          this->AppendTarget(fout, fastTarget, make, subdir, prefix);
           }
           break;
***************
*** 772,776 ****
--- 781,816 ----
          }
        }
+       
+     // insert the all and clean targets in every subdir
+     if (!allTarget.empty())
+       {
+       this->AppendTarget(fout, allTarget, make, subdir, ": ");
+       }
+     if (!cleanTarget.empty())
+       {
+       this->AppendTarget(fout, cleanTarget, make, subdir, ": ");
+       }
+ 
+     //insert rules for compiling, preprocessing and assembling individual files
+     cmLocalUnixMakefileGenerator3* lumg=(cmLocalUnixMakefileGenerator3*)*it;
+     std::vector<std::string> objectFileTargets;
+     lumg->GetIndividualFileTargets(objectFileTargets);
+     for(std::vector<std::string>::const_iterator fit=objectFileTargets.begin();
+         fit != objectFileTargets.end();
+         ++fit)
+       {
+       const char* prefix = "[obj] ";
+       if ((*fit)[fit->length()-1] == 's')
+         {
+         prefix = "[to asm] ";
+         }
+       else if ((*fit)[fit->length()-1] == 'i')
+         {
+         prefix = "[pre] ";
+         }
+       this->AppendTarget(fout, *fit, make, subdir, prefix);
+       }
      }
+ 
    fout << "</buildTargets>\n"
            "</storageModule>\n"
***************
*** 925,935 ****
  }
  
  void cmExtraEclipseCDT4Generator::AppendTarget(cmGeneratedFileStream& fout,
                                                 const std::string&     target,
!                                                const std::string&     make)
  {
    fout << 
!     "<target name=\"" << target << "\""
!     " path=\"\""
      " targetID=\"org.eclipse.cdt.make.MakeTargetBuilder\">\n"
      "<buildCommand>"
--- 965,985 ----
  }
  
+ // The prefix is prepended before the actual name of the target. The purpose
+ // of that is to sort the targets in the view of Eclipse, so that at first
+ // the global/utility/all/clean targets appear ": ", then the executable
+ // targets "[exe] ", then the libraries "[lib]", then the rules for the
+ // object files "[obj]", then for preprocessing only "[pre] " and 
+ // finally the assembly files "[to asm] ". Note the "to" in "to asm", 
+ // without it, "asm" would be the first targets in the list, with the "to"
+ // they are the last targets, which makes more sense.
  void cmExtraEclipseCDT4Generator::AppendTarget(cmGeneratedFileStream& fout,
                                                 const std::string&     target,
!                                                const std::string&     make,
!                                                const std::string&     path,
!                                                const char* prefix)
  {
    fout << 
!     "<target name=\"" << prefix << target << "\""
!     " path=\"" << path.c_str() << "\""
      " targetID=\"org.eclipse.cdt.make.MakeTargetBuilder\">\n"
      "<buildCommand>"



More information about the Cmake-commits mailing list