cmMakeDepend.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. /*=========================================================================
  2. Program: Insight Segmentation & Registration Toolkit
  3. Module: $RCSfile$
  4. Language: C++
  5. Date: $Date$
  6. Version: $Revision$
  7. Copyright (c) 2001 Insight Consortium
  8. All rights reserved.
  9. Redistribution and use in source and binary forms, with or without
  10. modification, are permitted provided that the following conditions are met:
  11. * Redistributions of source code must retain the above copyright notice,
  12. this list of conditions and the following disclaimer.
  13. * Redistributions in binary form must reproduce the above copyright notice,
  14. this list of conditions and the following disclaimer in the documentation
  15. and/or other materials provided with the distribution.
  16. * The name of the Insight Consortium, nor the names of any consortium members,
  17. nor of any contributors, may be used to endorse or promote products derived
  18. from this software without specific prior written permission.
  19. * Modified source versions must be plainly marked as such, and must not be
  20. misrepresented as being the original software.
  21. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS ``AS IS''
  22. AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  23. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  24. ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
  25. ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  26. DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  27. SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  28. CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  29. OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  30. OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  31. =========================================================================*/
  32. #ifndef cmMakeDepend_h
  33. #define cmMakeDepend_h
  34. #include "cmMakefile.h"
  35. #include "cmSourceFile.h"
  36. #include "cmRegularExpression.h"
  37. #include "cmStandardIncludes.h"
  38. /** \class cmDependInformation
  39. * \brief Store dependency information for a single source file.
  40. *
  41. * This structure stores the depend information for a single source file.
  42. */
  43. class cmDependInformation
  44. {
  45. public:
  46. /**
  47. * Construct with dependency generation marked not done; instance
  48. * not placed in cmMakefile's list.
  49. */
  50. cmDependInformation(): m_DependDone(false), m_cmSourceFile(0) {}
  51. /**
  52. * The set of files on which this one depends.
  53. */
  54. typedef std::set<cmDependInformation*> DependencySet;
  55. DependencySet m_DependencySet;
  56. /**
  57. * This flag indicates whether dependency checking has been
  58. * performed for this file.
  59. */
  60. bool m_DependDone;
  61. /**
  62. * If this object corresponds to a cmSourceFile instance, this points
  63. * to it.
  64. */
  65. const cmSourceFile *m_cmSourceFile;
  66. /**
  67. * Full path to this file.
  68. */
  69. std::string m_FullPath;
  70. /**
  71. * Name used to #include this file.
  72. */
  73. std::string m_IncludeName;
  74. /**
  75. * This method adds the dependencies of another file to this one.
  76. */
  77. void AddDependencies(cmDependInformation*);
  78. };
  79. // cmMakeDepend is used to generate dependancy information for
  80. // the classes in a makefile
  81. class cmMakeDepend
  82. {
  83. public:
  84. /**
  85. * Construct the object with verbose turned off.
  86. */
  87. cmMakeDepend();
  88. /**
  89. * Destructor.
  90. */
  91. virtual ~cmMakeDepend();
  92. /**
  93. * Set the makefile that is used as a source of classes.
  94. */
  95. virtual void SetMakefile(const cmMakefile* makefile);
  96. /**
  97. * Get the depend info struct for a source file
  98. */
  99. const cmDependInformation *GetDependInformationForSourceFile(const cmSourceFile &sf) const;
  100. /**
  101. * Add a directory to the search path for include files.
  102. */
  103. virtual void AddSearchPath(const char*);
  104. /**
  105. * Generate dependencies for all the sources of all the targets
  106. * in the makefile.
  107. */
  108. void GenerateMakefileDependencies();
  109. /**
  110. * Generate dependencies for the file given. Returns a pointer to
  111. * the cmDependInformation object for the file.
  112. */
  113. const cmDependInformation* FindDependencies(const char* file);
  114. protected:
  115. /**
  116. * Add a source file to the search path.
  117. */
  118. void AddFileToSearchPath(const char* filepath);
  119. /**
  120. * Compute the depend information for this class.
  121. */
  122. virtual void DependWalk(cmDependInformation* info);
  123. /**
  124. * Add a dependency. Possibly walk it for more dependencies.
  125. */
  126. virtual void AddDependency(cmDependInformation* info, const char* file);
  127. /**
  128. * Fill in the given object with dependency information. If the
  129. * information is already complete, nothing is done.
  130. */
  131. void GenerateDependInformation(cmDependInformation* info);
  132. /**
  133. * Get an instance of cmDependInformation corresponding to the given file
  134. * name.
  135. */
  136. cmDependInformation* GetDependInformation(const char* file);
  137. /**
  138. * Find the full path name for the given file name.
  139. * This uses the include directories.
  140. * TODO: Cache path conversions to reduce FileExists calls.
  141. */
  142. std::string FullPath(const char*);
  143. const cmMakefile* m_Makefile;
  144. bool m_Verbose;
  145. cmRegularExpression m_IncludeFileRegularExpression;
  146. cmRegularExpression m_ComplainFileRegularExpression;
  147. std::vector<std::string> m_IncludeDirectories;
  148. typedef std::map<cmStdString, cmDependInformation*> DependInformationMap;
  149. DependInformationMap m_DependInformationMap;
  150. };
  151. #endif