فهرست منبع

BUG: fix bug in depends

Bill Hoffman 23 سال پیش
والد
کامیت
5a676508c4
3فایلهای تغییر یافته به همراه34 افزوده شده و 18 حذف شده
  1. 30 12
      Source/cmLocalUnixMakefileGenerator.cxx
  2. 4 0
      Source/cmLocalUnixMakefileGenerator.h
  3. 0 6
      Source/cmMakeDepend.cxx

+ 30 - 12
Source/cmLocalUnixMakefileGenerator.cxx

@@ -91,6 +91,31 @@ void cmLocalUnixMakefileGenerator::Generate(bool fromTheTop)
   this->OutputMakefile(dest.c_str(), !fromTheTop); 
   this->OutputMakefile(dest.c_str(), !fromTheTop); 
 }
 }
 
 
+void 
+cmLocalUnixMakefileGenerator::AddDependenciesToSourceFile(cmDependInformation const *info,
+                                                          cmSourceFile *i,
+                                                          std::set<cmDependInformation const*> *visited)
+{
+  // add info to the visited set
+  visited->insert(info);
+    
+  // add this dependency and the recurse
+  if(info->m_FullPath != "")
+    {
+    // now recurse with info's dependencies
+    for(cmDependInformation::DependencySet::const_iterator d = 
+          info->m_DependencySet.begin();
+        d != info->m_DependencySet.end(); ++d)
+      {
+      if (visited->find(*d) == visited->end())
+        {
+        i->GetDepends().push_back((*d)->m_FullPath);
+        this->AddDependenciesToSourceFile(*d,i,visited);
+        }
+      }
+    }
+}
+
 void cmLocalUnixMakefileGenerator::ProcessDepends(const cmMakeDepend &md)
 void cmLocalUnixMakefileGenerator::ProcessDepends(const cmMakeDepend &md)
 {
 {
   // Now create cmDependInformation objects for files in the directory
   // Now create cmDependInformation objects for files in the directory
@@ -109,21 +134,14 @@ void cmLocalUnixMakefileGenerator::ProcessDepends(const cmMakeDepend &md)
         
         
         // Delete any hints from the source file's dependencies.
         // Delete any hints from the source file's dependencies.
         (*i)->GetDepends().erase((*i)->GetDepends().begin(), (*i)->GetDepends().end());
         (*i)->GetDepends().erase((*i)->GetDepends().begin(), (*i)->GetDepends().end());
-        
+        std::cerr << "get depends for " << (*i)->GetFullPath() << "\n";
+
         // Now add the real dependencies for the file.
         // Now add the real dependencies for the file.
         if (info)
         if (info)
           {
           {
-          for(cmDependInformation::DependencySet::const_iterator d = 
-                info->m_DependencySet.begin();
-              d != info->m_DependencySet.end(); ++d)
-            {
-            // Make sure the full path is given.  If not, the dependency was
-            // not found.
-            if((*d)->m_FullPath != "")
-              {
-              (*i)->GetDepends().push_back((*d)->m_FullPath);
-              }
-            }
+          // create visited set
+          std::set<cmDependInformation const*> visited;
+          this->AddDependenciesToSourceFile(info,*i, &visited);
           }
           }
         }
         }
       }
       }

+ 4 - 0
Source/cmLocalUnixMakefileGenerator.h

@@ -19,6 +19,7 @@
 
 
 #include "cmLocalGenerator.h"
 #include "cmLocalGenerator.h"
 
 
+class cmDependInformation;
 class cmMakeDepend;
 class cmMakeDepend;
 class cmTarget;
 class cmTarget;
 class cmSourceFile;
 class cmSourceFile;
@@ -77,6 +78,9 @@ public:
   void SetMakefileVariableSize(int s) { m_MakefileVariableSize = s; }
   void SetMakefileVariableSize(int s) { m_MakefileVariableSize = s; }
 
 
 protected:
 protected:
+  void AddDependenciesToSourceFile(cmDependInformation const*info,
+                                   cmSourceFile *i,
+                                   std::set<cmDependInformation const*> *visited);
   virtual const char* GetSafeDefinition(const char*);
   virtual const char* GetSafeDefinition(const char*);
   virtual void ProcessDepends(const cmMakeDepend &md);
   virtual void ProcessDepends(const cmMakeDepend &md);
   virtual void OutputMakefile(const char* file, bool withDepends);
   virtual void OutputMakefile(const char* file, bool withDepends);

+ 0 - 6
Source/cmMakeDepend.cxx

@@ -24,12 +24,6 @@ void cmDependInformation::AddDependencies(cmDependInformation* info)
   if(this != info)
   if(this != info)
     {
     {
     m_DependencySet.insert(info);
     m_DependencySet.insert(info);
-    for (cmDependInformation::DependencySet::const_iterator
-           d = info->m_DependencySet.begin(); 
-         d != info->m_DependencySet.end(); ++d)
-      {
-      m_DependencySet.insert(*d);
-      }
     }
     }
 }
 }