浏览代码

Exclude targets from the graphviz file based on a regex

This commit adds support for a GRAPHVIZ_TARGET_IGNORE_REGEX variable
which can be set() in CMakeGraphVizOptions.cmake.
Targets matching this regex will be skipped when generating the graphviz
graphs.

Alex
Alex Neundorf 15 年之前
父节点
当前提交
78c86f4542
共有 2 个文件被更改,包括 20 次插入2 次删除
  1. 19 1
      Source/cmGraphVizWriter.cxx
  2. 1 1
      Source/cmGraphVizWriter.h

+ 19 - 1
Source/cmGraphVizWriter.cxx

@@ -117,6 +117,17 @@ void cmGraphVizWriter::ReadSettings(const char* settingsFileName,
   __set_bool_if_set(this->GenerateForSharedLibs, "GRAPHVIZ_SHARED_LIBS");
   __set_bool_if_set(this->GenerateForModuleLibs , "GRAPHVIZ_MODULE_LIBS");
 
+  cmStdString tmpRegexString;
+  __set_if_set(tmpRegexString, "GRAPHVIZ_TARGET_IGNORE_REGEX");
+  if (tmpRegexString.size() > 0)
+    {
+    if (!this->TargetIgnoreRegex.compile(tmpRegexString.c_str()))
+      {
+      std::cerr << "Could not compile bad regex \"" << tmpRegexString << "\""
+                << std::endl;
+      }
+    }
+
   this->TargetsToIgnore.clear();
   const char* ignoreTargets = mf->GetDefinition("GRAPHVIZ_IGNORE_TARGETS");
   if ( ignoreTargets )
@@ -391,8 +402,15 @@ int cmGraphVizWriter::CollectAllExternalLibs(int cnt)
 }
 
 
-bool cmGraphVizWriter::IgnoreThisTarget(const char* name) const
+bool cmGraphVizWriter::IgnoreThisTarget(const char* name)
 {
+  if (this->TargetIgnoreRegex.is_valid())
+    {
+    if (this->TargetIgnoreRegex.find(name))
+      {
+      return true;
+      }
+    }
   return (this->TargetsToIgnore.find(name) != this->TargetsToIgnore.end());
 }
 

+ 1 - 1
Source/cmGraphVizWriter.h

@@ -54,7 +54,7 @@ protected:
 
   void WriteFooter(cmGeneratedFileStream& str) const;
 
-  bool IgnoreThisTarget(const char* name) const;
+  bool IgnoreThisTarget(const char* name);
 
   bool GenerateForTargetType(cmTarget::TargetType targetType) const;