cmMakeDepend.h 4.8 KB

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