浏览代码

Merge topic 'refactor-progress'

7fbc56ac cmGlobalUnixMakefileGenerator3: Implement progress in terms of cmState.
65c434e1 cmGlobalUnixMakefileGenerator3: Inline an IsExcluded call.
be56feb6 cmGlobalGenerator: Extract new IsExcluded overload.
45f52003 cmGlobalGenerator: Implement IsExcluded in terms of cmState::Snapshot.
af9fc277 cmState: Make Snapshot EqualityComparable.
9b44018d cmGlobalGenerator: Convert IsExcluded to loop.
5f05b562 cmGlobalGenerator: Refactor IsExcluded.
95925a60 cmGlobalGenerator: Don't use else after return.
Brad King 10 年之前
父节点
当前提交
2985b9c003
共有 5 个文件被更改,包括 62 次插入22 次删除
  1. 29 19
      Source/cmGlobalGenerator.cxx
  2. 2 0
      Source/cmGlobalGenerator.h
  3. 14 3
      Source/cmGlobalUnixMakefileGenerator3.cxx
  4. 10 0
      Source/cmState.cxx
  5. 7 0
      Source/cmState.h

+ 29 - 19
Source/cmGlobalGenerator.cxx

@@ -2041,24 +2041,37 @@ void cmGlobalGenerator::SetConfiguredFilesPath(cmGlobalGenerator* gen)
     }
 }
 
-bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root,
-                                   cmLocalGenerator* gen) const
+bool cmGlobalGenerator::IsExcluded(cmState::Snapshot const& rootSnp,
+                       cmState::Snapshot const& snp_) const
 {
-  if(!gen || gen == root)
+  cmState::Snapshot snp = snp_;
+  while (snp.IsValid())
     {
-    // No directory excludes itself.
-    return false;
-    }
+    if(snp == rootSnp)
+      {
+      // No directory excludes itself.
+      return false;
+      }
 
-  if(gen->GetMakefile()->GetPropertyAsBool("EXCLUDE_FROM_ALL"))
-    {
-    // This directory is excluded from its parent.
-    return true;
+    if(snp.GetDirectory().GetPropertyAsBool("EXCLUDE_FROM_ALL"))
+      {
+      // This directory is excluded from its parent.
+      return true;
+      }
+    snp = snp.GetBuildsystemDirectoryParent();
     }
+  return false;
+}
+
+bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root,
+                                   cmLocalGenerator* gen) const
+{
+  assert(gen);
+
+  cmState::Snapshot rootSnp = root->GetStateSnapshot();
+  cmState::Snapshot snp = gen->GetStateSnapshot();
 
-  // This directory is included in its parent.  Check whether the
-  // parent is excluded.
-  return this->IsExcluded(root, gen->GetParent());
+  return this->IsExcluded(rootSnp, snp);
 }
 
 bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root,
@@ -2070,12 +2083,9 @@ bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root,
     // This target is excluded from its directory.
     return true;
     }
-  else
-    {
-    // This target is included in its directory.  Check whether the
-    // directory is excluded.
-    return this->IsExcluded(root, target->GetLocalGenerator());
-    }
+  // This target is included in its directory.  Check whether the
+  // directory is excluded.
+  return this->IsExcluded(root, target->GetLocalGenerator());
 }
 
 void

+ 2 - 0
Source/cmGlobalGenerator.h

@@ -396,6 +396,8 @@ protected:
   // has been populated.
   void FillProjectMap();
   void CheckLocalGenerators();
+  bool IsExcluded(cmState::Snapshot const& root,
+                  cmState::Snapshot const& snp) const;
   bool IsExcluded(cmLocalGenerator* root, cmLocalGenerator* gen) const;
   bool IsExcluded(cmLocalGenerator* root, cmGeneratorTarget* target) const;
   virtual void InitializeProgressMarks() {}

+ 14 - 3
Source/cmGlobalUnixMakefileGenerator3.cxx

@@ -936,14 +936,25 @@ void cmGlobalUnixMakefileGenerator3::InitializeProgressMarks()
 
       cmGeneratorTarget* gt = this->GetGeneratorTarget(&target);
 
+      cmLocalGenerator* tlg = gt->GetLocalGenerator();
+
+      if(gt->GetType() == cmTarget::INTERFACE_LIBRARY
+          || gt->Target->GetPropertyAsBool("EXCLUDE_FROM_ALL"))
+        {
+        continue;
+        }
+
+      cmState::Snapshot csnp = lg->GetStateSnapshot();
+      cmState::Snapshot tsnp = tlg->GetStateSnapshot();
+
       // Consider the directory containing the target and all its
       // parents until something excludes the target.
-      for(cmLocalGenerator* clg = lg; clg && !this->IsExcluded(clg, gt);
-          clg = clg->GetParent())
+      for( ; csnp.IsValid() && !this->IsExcluded(csnp, tsnp);
+          csnp = csnp.GetBuildsystemDirectoryParent())
         {
         // This local generator includes the target.
         std::set<cmGeneratorTarget const*>& targetSet =
-          this->DirectoryTargetsMap[clg->GetStateSnapshot()];
+          this->DirectoryTargetsMap[csnp];
         targetSet.insert(gt);
 
         // Add dependencies of the included target.  An excluded

+ 10 - 0
Source/cmState.cxx

@@ -1701,3 +1701,13 @@ std::vector<std::string> cmState::Directory::GetPropertyKeys() const
     }
   return keys;
 }
+
+bool operator==(const cmState::Snapshot& lhs, const cmState::Snapshot& rhs)
+{
+  return lhs.Position == rhs.Position;
+}
+
+bool operator!=(const cmState::Snapshot& lhs, const cmState::Snapshot& rhs)
+{
+  return lhs.Position != rhs.Position;
+}

+ 7 - 0
Source/cmState.h

@@ -93,6 +93,10 @@ public:
     };
 
   private:
+    friend bool operator==(const cmState::Snapshot& lhs,
+                           const cmState::Snapshot& rhs);
+    friend bool operator!=(const cmState::Snapshot& lhs,
+                           const cmState::Snapshot& rhs);
     friend class cmState;
     friend class Directory;
     friend struct StrictWeakOrder;
@@ -314,4 +318,7 @@ private:
   bool MSYSShell;
 };
 
+bool operator==(const cmState::Snapshot& lhs, const cmState::Snapshot& rhs);
+bool operator!=(const cmState::Snapshot& lhs, const cmState::Snapshot& rhs);
+
 #endif