[Cmake-commits] [cmake-commits] king committed cmTarget.cxx 1.270 1.271 cmTarget.h 1.141 1.142

cmake-commits at cmake.org cmake-commits at cmake.org
Mon Sep 7 10:11:47 EDT 2009


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

Modified Files:
	cmTarget.cxx cmTarget.h 
Log Message:
Save source dependencies from custom command trace

In each target we trace dependencies among custom commands to pull in
all source files and build rules necessary to complete the target.  This
commit teaches cmTarget to save the inter-source dependencies found
during its analysis.  Later this can be used by generators that need to
topologically order custom command rules.


Index: cmTarget.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmTarget.h,v
retrieving revision 1.141
retrieving revision 1.142
diff -C 2 -d -r1.141 -r1.142
*** cmTarget.h	4 Sep 2009 16:39:05 -0000	1.141
--- cmTarget.h	7 Sep 2009 14:11:43 -0000	1.142
***************
*** 49,52 ****
--- 49,53 ----
    cmTargetInternalPointer& operator=(cmTargetInternalPointer const& r);
    cmTargetInternals* operator->() const { return this->Pointer; }
+   cmTargetInternals* Get() const { return this->Pointer; }
  private:
    cmTargetInternals* Pointer;
***************
*** 123,126 ****
--- 124,130 ----
    void AddSourceFile(cmSourceFile* sf);
  
+   /** Get sources that must be built before the given source.  */
+   std::vector<cmSourceFile*> const* GetSourceDepends(cmSourceFile* sf);
+ 
    /**
     * Flags for a given source file as used in this target. Typically assigned
***************
*** 531,535 ****
    TargetType TargetTypeValue;
    std::vector<cmSourceFile*> SourceFiles;
-   std::set<cmSourceFile*> SourceFileSet;
    LinkLibraryVectorType LinkLibraries;
    LinkLibraryVectorType PrevLinkedLibraries;
--- 535,538 ----

Index: cmTarget.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmTarget.cxx,v
retrieving revision 1.270
retrieving revision 1.271
diff -C 2 -d -r1.270 -r1.271
*** cmTarget.cxx	4 Sep 2009 16:39:18 -0000	1.270
--- cmTarget.cxx	7 Sep 2009 14:11:42 -0000	1.271
***************
*** 89,92 ****
--- 89,96 ----
    typedef std::map<cmStdString, cmTarget::LinkClosure> LinkClosureMapType;
    LinkClosureMapType LinkClosureMap;
+ 
+   struct SourceEntry { std::vector<cmSourceFile*> Depends; };
+   typedef std::map<cmSourceFile*, SourceEntry> SourceEntriesType;
+   SourceEntriesType SourceEntries;
  };
  
***************
*** 1082,1091 ****
  {
  public:
!   cmTargetTraceDependencies(cmTarget* target, const char* vsProjectFile);
    void Trace();
  private:
    cmTarget* Target;
    cmMakefile* Makefile;
    cmGlobalGenerator* GlobalGenerator;
    std::queue<cmSourceFile*> SourceQueue;
    std::set<cmSourceFile*> SourcesQueued;
--- 1086,1099 ----
  {
  public:
!   cmTargetTraceDependencies(cmTarget* target, cmTargetInternals* internal,
!                             const char* vsProjectFile);
    void Trace();
  private:
    cmTarget* Target;
+   cmTargetInternals* Internal;
    cmMakefile* Makefile;
    cmGlobalGenerator* GlobalGenerator;
+   typedef cmTargetInternals::SourceEntry SourceEntry;
+   SourceEntry* CurrentEntry;
    std::queue<cmSourceFile*> SourceQueue;
    std::set<cmSourceFile*> SourcesQueued;
***************
*** 1103,1108 ****
  //----------------------------------------------------------------------------
  cmTargetTraceDependencies
! ::cmTargetTraceDependencies(cmTarget* target, const char* vsProjectFile):
!   Target(target)
  {
    // Convenience.
--- 1111,1117 ----
  //----------------------------------------------------------------------------
  cmTargetTraceDependencies
! ::cmTargetTraceDependencies(cmTarget* target, cmTargetInternals* internal,
!                             const char* vsProjectFile):
!   Target(target), Internal(internal)
  {
    // Convenience.
***************
*** 1110,1113 ****
--- 1119,1123 ----
    this->GlobalGenerator =
      this->Makefile->GetLocalGenerator()->GetGlobalGenerator();
+   this->CurrentEntry = 0;
  
    // Queue all the source files already specified for the target.
***************
*** 1141,1144 ****
--- 1151,1155 ----
      cmSourceFile* sf = this->SourceQueue.front();
      this->SourceQueue.pop();
+     this->CurrentEntry = &this->Internal->SourceEntries[sf];
  
      // Queue dependencies added explicitly by the user.
***************
*** 1162,1165 ****
--- 1173,1177 ----
        }
      }
+   this->CurrentEntry = 0;
  }
  
***************
*** 1189,1192 ****
--- 1201,1210 ----
    if(cmSourceFile* sf = i->second)
      {
+     // Record the dependency we just followed.
+     if(this->CurrentEntry)
+       {
+       this->CurrentEntry->Depends.push_back(sf);
+       }
+ 
      this->QueueSource(sf);
      }
***************
*** 1309,1313 ****
  {
    // Use a helper object to trace the dependencies.
!   cmTargetTraceDependencies tracer(this, vsProjectFile);
    tracer.Trace();
  }
--- 1327,1331 ----
  {
    // Use a helper object to trace the dependencies.
!   cmTargetTraceDependencies tracer(this, this->Internal.Get(), vsProjectFile);
    tracer.Trace();
  }
***************
*** 1337,1342 ****
  void cmTarget::AddSourceFile(cmSourceFile* sf)
  {
!   if(this->SourceFileSet.insert(sf).second)
      {
      this->SourceFiles.push_back(sf);
      }
--- 1355,1365 ----
  void cmTarget::AddSourceFile(cmSourceFile* sf)
  {
!   typedef cmTargetInternals::SourceEntriesType SourceEntriesType;
!   SourceEntriesType::iterator i = this->Internal->SourceEntries.find(sf);
!   if(i == this->Internal->SourceEntries.end())
      {
+     typedef cmTargetInternals::SourceEntry SourceEntry;
+     SourceEntriesType::value_type entry(sf, SourceEntry());
+     i = this->Internal->SourceEntries.insert(entry).first;
      this->SourceFiles.push_back(sf);
      }
***************
*** 1344,1347 ****
--- 1367,1383 ----
  
  //----------------------------------------------------------------------------
+ std::vector<cmSourceFile*> const*
+ cmTarget::GetSourceDepends(cmSourceFile* sf)
+ {
+   typedef cmTargetInternals::SourceEntriesType SourceEntriesType;
+   SourceEntriesType::iterator i = this->Internal->SourceEntries.find(sf);
+   if(i != this->Internal->SourceEntries.end())
+     {
+     return &i->second.Depends;
+     }
+   return 0;
+ }
+ 
+ //----------------------------------------------------------------------------
  void cmTarget::AddSources(std::vector<std::string> const& srcs)
  {



More information about the Cmake-commits mailing list