cmMakeDepend.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  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()
  51. {
  52. m_DependDone = false;
  53. m_ClassFileIndex = 0;
  54. }
  55. /**
  56. * A set of indices into the m_DependInformation array of cmMakeDepend.
  57. * The index represents the files that this file depends on.
  58. * This must be a "set" to keep indices unique.
  59. */
  60. typedef std::set<int> IndexSet;
  61. IndexSet m_IndexSet;
  62. /**
  63. * Full path to this file.
  64. */
  65. std::string m_FullPath;
  66. /**
  67. * Name that the include directive uses.
  68. */
  69. std::string m_IncludeName;
  70. /**
  71. * The index into the cmMakefile::m_Classes list.
  72. * The index value of 0 indicates that it is not in the list.
  73. */
  74. const cmSourceFile *m_ClassFileIndex;
  75. /**
  76. * This flag indicates whether dependency checking has been
  77. * performed for this file.
  78. */
  79. bool m_DependDone;
  80. /**
  81. * This method adds the dependencies of another file to this one.
  82. */
  83. void MergeInfo(cmDependInformation*);
  84. };
  85. // cmMakeDepend is used to generate dependancy information for
  86. // the classes in a makefile
  87. class cmMakeDepend
  88. {
  89. public:
  90. /**
  91. * Construct the object with verbose turned off.
  92. */
  93. cmMakeDepend();
  94. /**
  95. * Destructor.
  96. */
  97. virtual ~cmMakeDepend();
  98. /**
  99. * Set the makefile that is used as a source of classes.
  100. */
  101. virtual void SetMakefile(const cmMakefile* makefile);
  102. /**
  103. * Generate the depend information
  104. */
  105. virtual void GenerateDependInformation();
  106. /**
  107. * Get the depend info struct for a source file
  108. */
  109. const cmDependInformation *GetDependInformationForSourceFile(const cmSourceFile &sf) const;
  110. const cmDependInformation *GetDependInformationForSourceFile(const char *) const;
  111. /**
  112. * Get the depend info struct
  113. */
  114. typedef std::vector<cmDependInformation*> DependArray;
  115. const DependArray &GetDependInformation() const {
  116. return m_DependInformation; }
  117. /**
  118. * Add a directory to the search path for include files.
  119. */
  120. virtual void AddSearchPath(const char*);
  121. protected:
  122. /**
  123. * Add a source file to the search path.
  124. */
  125. void AddFileToSearchPath(const char* filepath);
  126. /**
  127. * Find the index into the m_DependInformation array
  128. * that matches the given m_IncludeName.
  129. */
  130. virtual int FindInformation(const char* includeName);
  131. /**
  132. * Compute the depend information for this class.
  133. */
  134. virtual void Depend(cmDependInformation* info);
  135. /**
  136. * Compute the depend information for this class.
  137. */
  138. virtual void DependWalk(cmDependInformation* info, const char* file);
  139. /**
  140. * Add a dependency. Possibly walk it for more dependencies.
  141. */
  142. virtual void AddDependency(cmDependInformation* info, const char* file);
  143. /**
  144. * Find the full path name for the given file name.
  145. * This uses the include directories.
  146. */
  147. std::string FullPath(const char*);
  148. const cmMakefile* m_Makefile;
  149. bool m_Verbose;
  150. cmRegularExpression m_IncludeFileRegularExpression;
  151. cmRegularExpression m_ComplainFileRegularExpression;
  152. DependArray m_DependInformation;
  153. std::vector<std::string> m_IncludeDirectories;
  154. };
  155. #endif