[Cmake-commits] [cmake-commits] king committed cmTarget.cxx 1.269 1.270

cmake-commits at cmake.org cmake-commits at cmake.org
Fri Sep 4 12:39:24 EDT 2009


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

Modified Files:
	cmTarget.cxx 
Log Message:
Cleanup source file dependency tracing logic

In cmTarget we trace the dependencies of source files in the target to
bring in all custom commands needed to generate them.  We clean up the
implementation to use simpler logic and better method names.  The new
approach is based on the observation that a source file is actually an
input (dependency) of the rule that it runs (compiler or custom) even in
the case that it is generated (another .rule file has the rule to
generate it).


Index: cmTarget.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmTarget.cxx,v
retrieving revision 1.269
retrieving revision 1.270
diff -C 2 -d -r1.269 -r1.270
*** cmTarget.cxx	4 Sep 2009 16:39:05 -0000	1.269
--- cmTarget.cxx	4 Sep 2009 16:39:18 -0000	1.270
***************
*** 1088,1097 ****
    cmMakefile* Makefile;
    cmGlobalGenerator* GlobalGenerator;
!   std::queue<cmStdString> DependencyQueue;
!   std::set<cmStdString> DependenciesQueued;
  
!   void QueueOnce(std::string const& name);
!   void QueueOnce(std::vector<std::string> const& names);
!   void QueueDependencies(cmSourceFile* sf);
    bool IsUtility(std::string const& dep);
    void CheckCustomCommand(cmCustomCommand const& cc);
--- 1088,1099 ----
    cmMakefile* Makefile;
    cmGlobalGenerator* GlobalGenerator;
!   std::queue<cmSourceFile*> SourceQueue;
!   std::set<cmSourceFile*> SourcesQueued;
!   typedef std::map<cmStdString, cmSourceFile*> NameMapType;
!   NameMapType NameMap;
  
!   void QueueSource(cmSourceFile* sf);
!   void FollowName(std::string const& name);
!   void FollowNames(std::vector<std::string> const& names);
    bool IsUtility(std::string const& dep);
    void CheckCustomCommand(cmCustomCommand const& cc);
***************
*** 1114,1123 ****
        si != sources.end(); ++si)
      {
!     // Queue the source file itself in case it is generated.
!     this->QueueOnce((*si)->GetFullPath());
! 
!     // Queue the dependencies of the source file in case they are
!     // generated.
!     this->QueueDependencies(*si);
      }
  
--- 1116,1120 ----
        si != sources.end(); ++si)
      {
!     this->QueueSource(*si);
      }
  
***************
*** 1126,1130 ****
    if(vsProjectFile)
      {
!     this->QueueOnce(vsProjectFile);
      }
  
--- 1123,1127 ----
    if(vsProjectFile)
      {
!     this->FollowName(vsProjectFile);
      }
  
***************
*** 1139,1157 ****
  {
    // Process one dependency at a time until the queue is empty.
!   while(!this->DependencyQueue.empty())
      {
!     // Get the next dependency in from queue.
!     std::string dep = this->DependencyQueue.front();
!     this->DependencyQueue.pop();
  
!     // Check if we know how to generate this dependency.
!     if(cmSourceFile* sf =
!        this->Makefile->GetSourceFileWithOutput(dep.c_str()))
        {
!       // Queue dependencies needed to generate this file.
!       this->QueueDependencies(sf);
  
!       // Make sure this file is in the target.
!       this->Target->AddSourceFile(sf);
        }
      }
--- 1136,1163 ----
  {
    // Process one dependency at a time until the queue is empty.
!   while(!this->SourceQueue.empty())
      {
!     // Get the next source from the queue.
!     cmSourceFile* sf = this->SourceQueue.front();
!     this->SourceQueue.pop();
  
!     // Queue dependencies added explicitly by the user.
!     if(const char* additionalDeps = sf->GetProperty("OBJECT_DEPENDS"))
        {
!       std::vector<std::string> objDeps;
!       cmSystemTools::ExpandListArgument(additionalDeps, objDeps);
!       this->FollowNames(objDeps);
!       }
  
!     // Queue the source needed to generate this file, if any.
!     this->FollowName(sf->GetFullPath());
! 
!     // Queue dependencies added programatically by commands.
!     this->FollowNames(sf->GetDepends());
! 
!     // Queue custom command dependencies.
!     if(cmCustomCommand const* cc = sf->GetCustomCommand())
!       {
!       this->CheckCustomCommand(*cc);
        }
      }
***************
*** 1159,1167 ****
  
  //----------------------------------------------------------------------------
! void cmTargetTraceDependencies::QueueOnce(std::string const& name)
  {
!   if(this->DependenciesQueued.insert(name).second)
      {
!     this->DependencyQueue.push(name);
      }
  }
--- 1165,1193 ----
  
  //----------------------------------------------------------------------------
! void cmTargetTraceDependencies::QueueSource(cmSourceFile* sf)
  {
!   if(this->SourcesQueued.insert(sf).second)
      {
!     this->SourceQueue.push(sf);
! 
!     // Make sure this file is in the target.
!     this->Target->AddSourceFile(sf);
!     }
! }
! 
! //----------------------------------------------------------------------------
! void cmTargetTraceDependencies::FollowName(std::string const& name)
! {
!   NameMapType::iterator i = this->NameMap.find(name);
!   if(i == this->NameMap.end())
!     {
!     // Check if we know how to generate this file.
!     cmSourceFile* sf = this->Makefile->GetSourceFileWithOutput(name.c_str());
!     NameMapType::value_type entry(name, sf);
!     i = this->NameMap.insert(entry).first;
!     }
!   if(cmSourceFile* sf = i->second)
!     {
!     this->QueueSource(sf);
      }
  }
***************
*** 1169,1178 ****
  //----------------------------------------------------------------------------
  void
! cmTargetTraceDependencies::QueueOnce(std::vector<std::string> const& names)
  {
    for(std::vector<std::string>::const_iterator i = names.begin();
        i != names.end(); ++i)
      {
!     this->QueueOnce(*i);
      }
  }
--- 1195,1204 ----
  //----------------------------------------------------------------------------
  void
! cmTargetTraceDependencies::FollowNames(std::vector<std::string> const& names)
  {
    for(std::vector<std::string>::const_iterator i = names.begin();
        i != names.end(); ++i)
      {
!     this->FollowName(*i);
      }
  }
***************
*** 1228,1253 ****
  
  //----------------------------------------------------------------------------
- void cmTargetTraceDependencies::QueueDependencies(cmSourceFile* sf)
- {
-   // Queue dependency added explicitly by the user.
-   if(const char* additionalDeps = sf->GetProperty("OBJECT_DEPENDS"))
-     {
-     std::vector<std::string> objDeps;
-     cmSystemTools::ExpandListArgument(additionalDeps, objDeps);
-     this->QueueOnce(objDeps);
-     }
- 
-   // Queue dependencies added programatically by commands.
-   this->QueueOnce(sf->GetDepends());
- 
-   // Queue custom command dependencies.
-   if(cmCustomCommand const* cc = sf->GetCustomCommand())
-     {
-     this->CheckCustomCommand(*cc);
-     }
- 
- }
- 
- //----------------------------------------------------------------------------
  void
  cmTargetTraceDependencies
--- 1254,1257 ----
***************
*** 1284,1288 ****
        // The dependency does not name a target and may be a file we
        // know how to generate.  Queue it.
!       this->QueueOnce(dep);
        }
      }
--- 1288,1292 ----
        // The dependency does not name a target and may be a file we
        // know how to generate.  Queue it.
!       this->FollowName(dep);
        }
      }



More information about the Cmake-commits mailing list