packaging: Initial packaging
[platform/upstream/cmake.git] / Source / cmGraphVizWriter.h
1 #ifndef CMGRAPHVIZWRITER_H
2 #define CMGRAPHVIZWRITER_H
3 /*============================================================================
4   CMake - Cross Platform Makefile Generator
5   Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
6
7   Distributed under the OSI-approved BSD License (the "License");
8   see accompanying file Copyright.txt for details.
9
10   This software is distributed WITHOUT ANY WARRANTY; without even the
11   implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12   See the License for more information.
13 ============================================================================*/
14 #include "cmStandardIncludes.h"
15 #include "cmLocalGenerator.h"
16 #include "cmGeneratedFileStream.h"
17 #include "cmTarget.h"
18 #include <cmsys/RegularExpression.hxx>
19
20
21 /** This class implements writing files for graphviz (dot) for graphs
22  * representing the dependencies between the targets in the project. */
23 class cmGraphVizWriter
24 {
25 public:
26
27   cmGraphVizWriter(const std::vector<cmLocalGenerator*>& localGenerators);
28
29   void ReadSettings(const char* settingsFileName,
30                     const char* fallbackSettingsFileName);
31
32   void WritePerTargetFiles(const char* fileName);
33   void WriteTargetDependersFiles(const char* fileName);
34
35   void WriteGlobalFile(const char* fileName);
36
37 protected:
38
39   void CollectTargetsAndLibs();
40
41   int CollectAllTargets();
42
43   int CollectAllExternalLibs(int cnt);
44
45   void WriteHeader(cmGeneratedFileStream& str) const;
46
47   void WriteConnections(const char* targetName,
48                         std::set<std::string>& insertedNodes,
49                         std::set<std::string>& insertedConnections,
50                         cmGeneratedFileStream& str) const;
51
52   void WriteDependerConnections(const char* targetName,
53                                 std::set<std::string>& insertedNodes,
54                                 std::set<std::string>& insertedConnections,
55                                 cmGeneratedFileStream& str) const;
56
57   void WriteNode(const char* targetName, const cmTarget* target,
58                  std::set<std::string>& insertedNodes,
59                  cmGeneratedFileStream& str) const;
60
61   void WriteFooter(cmGeneratedFileStream& str) const;
62
63   bool IgnoreThisTarget(const char* name);
64
65   bool GenerateForTargetType(cmTarget::TargetType targetType) const;
66
67   cmStdString GraphType;
68   cmStdString GraphName;
69   cmStdString GraphHeader;
70   cmStdString GraphNodePrefix;
71
72   bool GenerateForExecutables;
73   bool GenerateForStaticLibs;
74   bool GenerateForSharedLibs;
75   bool GenerateForModuleLibs;
76   bool GenerateForExternals;
77
78   std::vector<cmsys::RegularExpression> TargetsToIgnoreRegex;
79
80   const std::vector<cmLocalGenerator*>& LocalGenerators;
81
82   std::map<cmStdString, const cmTarget*> TargetPtrs;
83   // maps from the actual target names to node names in dot:
84   std::map<cmStdString, cmStdString> TargetNamesNodes;
85
86   bool HaveTargetsAndLibs;
87 };
88
89 #endif