packaging: Initial packaging
[platform/upstream/cmake.git] / Source / cmMakeDepend.h
1 /*============================================================================
2   CMake - Cross Platform Makefile Generator
3   Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
4
5   Distributed under the OSI-approved BSD License (the "License");
6   see accompanying file Copyright.txt for details.
7
8   This software is distributed WITHOUT ANY WARRANTY; without even the
9   implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10   See the License for more information.
11 ============================================================================*/
12 #ifndef cmMakeDepend_h
13 #define cmMakeDepend_h
14
15 #include "cmMakefile.h"
16 #include "cmSourceFile.h"
17
18 #include <cmsys/RegularExpression.hxx>
19
20 /** \class cmDependInformation
21  * \brief Store dependency information for a single source file.
22  *
23  * This structure stores the depend information for a single source file.
24  */
25 class cmDependInformation
26 {
27 public:
28   /**
29    * Construct with dependency generation marked not done; instance
30    * not placed in cmMakefile's list.
31    */
32   cmDependInformation(): DependDone(false), SourceFile(0) {}
33
34   /**
35    * The set of files on which this one depends.
36    */
37   typedef std::set<cmDependInformation*> DependencySetType;
38   DependencySetType DependencySet;
39
40   /**
41    * This flag indicates whether dependency checking has been
42    * performed for this file.
43    */
44   bool DependDone;
45
46   /**
47    * If this object corresponds to a cmSourceFile instance, this points
48    * to it.
49    */
50   const cmSourceFile *SourceFile;
51
52   /**
53    * Full path to this file.
54    */
55   std::string FullPath;
56
57   /**
58    * Full path not including file name.
59    */
60   std::string PathOnly;
61
62   /**
63    * Name used to #include this file.
64    */
65   std::string IncludeName;
66
67   /**
68    * This method adds the dependencies of another file to this one.
69    */
70   void AddDependencies(cmDependInformation*);
71 };
72
73
74 // cmMakeDepend is used to generate dependancy information for
75 // the classes in a makefile
76 class cmMakeDepend
77 {
78 public:
79   /**
80    * Construct the object with verbose turned off.
81    */
82   cmMakeDepend();
83
84   /**
85    * Destructor.
86    */
87   virtual ~cmMakeDepend();
88
89   /**
90    * Set the makefile that is used as a source of classes.
91    */
92   virtual void SetMakefile(cmMakefile* makefile);
93
94   /**
95    * Add a directory to the search path for include files.
96    */
97   virtual void AddSearchPath(const char*);
98
99   /**
100    * Generate dependencies for the file given.  Returns a pointer to
101    * the cmDependInformation object for the file.
102    */
103   const cmDependInformation* FindDependencies(const char* file);
104
105 protected:
106   /**
107    * Compute the depend information for this class.
108    */
109   virtual void DependWalk(cmDependInformation* info);
110
111   /**
112    * Add a dependency.  Possibly walk it for more dependencies.
113    */
114   virtual void AddDependency(cmDependInformation* info, const char* file);
115
116   /**
117    * Fill in the given object with dependency information.  If the
118    * information is already complete, nothing is done.
119    */
120   void GenerateDependInformation(cmDependInformation* info);
121
122   /**
123    * Get an instance of cmDependInformation corresponding to the given file
124    * name.
125    */
126   cmDependInformation* GetDependInformation(const char* file,
127                                             const char *extraPath);
128
129   /**
130    * Find the full path name for the given file name.
131    * This uses the include directories.
132    * TODO: Cache path conversions to reduce FileExists calls.
133    */
134   std::string FullPath(const char *filename, const char *extraPath);
135
136   cmMakefile* Makefile;
137   bool Verbose;
138   cmsys::RegularExpression IncludeFileRegularExpression;
139   cmsys::RegularExpression ComplainFileRegularExpression;
140   std::vector<std::string> IncludeDirectories;
141   typedef std::map<cmStdString, cmStdString> FileToPathMapType;
142   typedef std::map<cmStdString, FileToPathMapType>
143   DirectoryToFileToPathMapType;
144   typedef std::map<cmStdString, cmDependInformation*>
145   DependInformationMapType;
146   DependInformationMapType DependInformationMap;
147   DirectoryToFileToPathMapType DirectoryToFileToPathMap;
148 };
149
150 #endif