Quellcode durchsuchen

VS: Simplify object name computation

Simplify cmLocalVisualStudioGenerator::ComputeObjectNameRequirements to
loop over the original vector of source files instead of recursively
traversing source groups just to find the same files.  Drop from
cmVisualStudio10TargetGenerator::ComputeObjectNames temporary source
group calculation now that it is not needed for computing object names.
Brad King vor 13 Jahren
Ursprung
Commit
67734be8cf

+ 1 - 1
Source/cmLocalVisualStudio6Generator.cxx

@@ -380,7 +380,7 @@ void cmLocalVisualStudio6Generator::WriteDSPFile(std::ostream& fout,
     }
 
   // Compute which sources need unique object computation.
-  this->ComputeObjectNameRequirements(sourceGroups);
+  this->ComputeObjectNameRequirements(classes);
   
   // Write the DSP file's header.
   this->WriteDSPHeader(fout, libName, target, sourceGroups);

+ 1 - 1
Source/cmLocalVisualStudio7Generator.cxx

@@ -1307,7 +1307,7 @@ void cmLocalVisualStudio7Generator::WriteVCProjFile(std::ostream& fout,
     }
 
   // Compute which sources need unique object computation.
-  this->ComputeObjectNameRequirements(sourceGroups);
+  this->ComputeObjectNameRequirements(classes);
 
   // open the project
   this->WriteProjectStart(fout, libName, target, sourceGroups);

+ 30 - 57
Source/cmLocalVisualStudioGenerator.cxx

@@ -83,77 +83,50 @@ bool cmLocalVisualStudioGenerator::SourceFileCompiles(const cmSourceFile* sf)
 }
 
 //----------------------------------------------------------------------------
-void cmLocalVisualStudioGenerator::CountObjectNames(
-    const std::vector<cmSourceGroup>& groups,
-    std::map<cmStdString, int>& counts)
+void
+cmLocalVisualStudioGenerator::ComputeObjectNameRequirements(
+  std::vector<cmSourceFile*> const& sources
+  )
 {
-  for(unsigned int i = 0; i < groups.size(); ++i)
+  // Clear the current set of requirements.
+  this->NeedObjectName.clear();
+
+  // Count the number of object files with each name.  Note that
+  // windows file names are not case sensitive.
+  std::map<cmStdString, int> counts;
+  for(std::vector<cmSourceFile*>::const_iterator s = sources.begin();
+      s != sources.end(); ++s)
     {
-    cmSourceGroup sg = groups[i];
-    std::vector<const cmSourceFile*> const& srcs = sg.GetSourceFiles();
-    for(std::vector<const cmSourceFile*>::const_iterator s = srcs.begin();
-        s != srcs.end(); ++s)
+    const cmSourceFile* sf = *s;
+    if(this->SourceFileCompiles(sf))
       {
-      const cmSourceFile* sf = *s;
-      if(this->SourceFileCompiles(sf))
-        {
-        std::string objectName = cmSystemTools::LowerCase(
-            cmSystemTools::GetFilenameWithoutLastExtension(
-              sf->GetFullPath()));
-        objectName += ".obj";
-        counts[objectName] += 1;
-        }
+      std::string objectName = cmSystemTools::LowerCase(
+        cmSystemTools::GetFilenameWithoutLastExtension(
+          sf->GetFullPath()));
+      objectName += ".obj";
+      counts[objectName] += 1;
       }
-    this->CountObjectNames(sg.GetGroupChildren(), counts);
     }
-}
 
-//----------------------------------------------------------------------------
-void cmLocalVisualStudioGenerator::InsertNeedObjectNames(
-   const std::vector<cmSourceGroup>& groups,
-    std::map<cmStdString, int>& count)
-{
-  for(unsigned int i = 0; i < groups.size(); ++i)
+  // For all source files producing duplicate names we need unique
+  // object name computation.
+  for(std::vector<cmSourceFile*>::const_iterator s = sources.begin();
+      s != sources.end(); ++s)
     {
-    cmSourceGroup sg = groups[i];
-    std::vector<const cmSourceFile*> const& srcs = sg.GetSourceFiles();
-    for(std::vector<const cmSourceFile*>::const_iterator s = srcs.begin();
-        s != srcs.end(); ++s)
+    const cmSourceFile* sf = *s;
+    if(this->SourceFileCompiles(sf))
       {
-      const cmSourceFile* sf = *s;
-      if(this->SourceFileCompiles(sf))
+      std::string objectName = cmSystemTools::LowerCase(
+         cmSystemTools::GetFilenameWithoutLastExtension(sf->GetFullPath()));
+      objectName += ".obj";
+      if(counts[objectName] > 1)
         {
-        std::string objectName = cmSystemTools::LowerCase(
-           cmSystemTools::GetFilenameWithoutLastExtension(sf->GetFullPath()));
-        objectName += ".obj";
-        if(count[objectName] > 1)
-          {
-          this->NeedObjectName.insert(sf);
-          }
+        this->NeedObjectName.insert(sf);
         }
       }
-    this->InsertNeedObjectNames(sg.GetGroupChildren(), count);
     }
 }
 
-
-//----------------------------------------------------------------------------
-void cmLocalVisualStudioGenerator::ComputeObjectNameRequirements
-(std::vector<cmSourceGroup> const& sourceGroups)
-{
-  // Clear the current set of requirements.
-  this->NeedObjectName.clear();
-
-  // Count the number of object files with each name.  Note that
-  // windows file names are not case sensitive.
-  std::map<cmStdString, int> objectNameCounts;
-  this->CountObjectNames(sourceGroups, objectNameCounts);
-
-  // For all source files producing duplicate names we need unique
-  // object name computation.
-  this->InsertNeedObjectNames(sourceGroups, objectNameCounts);
-}
-
 //----------------------------------------------------------------------------
 const char* cmLocalVisualStudioGenerator::ReportErrorLabel() const
 {

+ 1 - 5
Source/cmLocalVisualStudioGenerator.h

@@ -65,12 +65,8 @@ protected:
   MaybeCreateImplibDir(cmTarget& target, const char* config, bool isFortran);
 
   // Safe object file name generation.
-  void ComputeObjectNameRequirements(std::vector<cmSourceGroup> const&);
+  void ComputeObjectNameRequirements(std::vector<cmSourceFile*> const&);
   bool SourceFileCompiles(const cmSourceFile* sf);
-  void CountObjectNames(const std::vector<cmSourceGroup>& groups,
-                        std::map<cmStdString, int>& count);
-  void InsertNeedObjectNames(const std::vector<cmSourceGroup>& groups,
-                             std::map<cmStdString, int>& count);
   std::set<const cmSourceFile*> NeedObjectName;
   friend class cmVisualStudio10TargetGenerator;
 

+ 1 - 7
Source/cmVisualStudio10TargetGenerator.cxx

@@ -872,9 +872,6 @@ void cmVisualStudio10TargetGenerator::WriteCLSources()
 
 void cmVisualStudio10TargetGenerator::ComputeObjectNames()
 {
-  // We may be modifying the source groups temporarily, so make a copy.
-  std::vector<cmSourceGroup> sourceGroups = this->Makefile->GetSourceGroups();
-
   // get the classes from the source lists then add them to the groups
   std::vector<cmSourceFile*>const & classes = this->Target->GetSourceFiles();
   for(std::vector<cmSourceFile*>::const_iterator i = classes.begin();
@@ -886,13 +883,10 @@ void cmVisualStudio10TargetGenerator::ComputeObjectNames()
       {
       this->ModuleDefinitionFile = (*i)->GetFullPath();
       }
-    cmSourceGroup& sourceGroup =
-      this->Makefile->FindSourceGroup(source.c_str(), sourceGroups);
-    sourceGroup.AssignSource(*i);
     }
 
   // Compute which sources need unique object computation.
-  this->LocalGenerator->ComputeObjectNameRequirements(sourceGroups);
+  this->LocalGenerator->ComputeObjectNameRequirements(classes);
 }
 
 bool cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags(