cmMakeDepend.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. /*=========================================================================
  2. Program: Insight Segmentation & Registration Toolkit
  3. Module: $RCSfile$
  4. Language: C++
  5. Date: $Date$
  6. Version: $Revision$
  7. Copyright (c) 2000 National Library of Medicine
  8. All rights reserved.
  9. See COPYRIGHT.txt for copyright details.
  10. =========================================================================*/
  11. #ifndef cmMakeDepend_h
  12. #define cmMakeDepend_h
  13. #include "cmMakefile.h"
  14. #include "cmClassFile.h"
  15. #include "cmRegularExpression.h"
  16. #include "cmStandardIncludes.h"
  17. /** \class cmDependInformation
  18. * \brief Store dependency information for a single source file.
  19. *
  20. * This structure stores the depend information for a single source file.
  21. */
  22. struct cmDependInformation
  23. {
  24. /**
  25. * Construct with dependency generation marked not done; instance
  26. * not placed in cmMakefile's list.
  27. */
  28. cmDependInformation()
  29. {
  30. m_DependDone = false;
  31. m_ClassFileIndex = -1;
  32. }
  33. /**
  34. * A list of indices into the m_DependInformation array of cmMakeDepend.
  35. * The index represents the files that this file depends on.
  36. */
  37. std::vector<int> m_Indices;
  38. /**
  39. * Full path to this file.
  40. */
  41. std::string m_FullPath;
  42. /**
  43. * Name that the include directive uses.
  44. */
  45. std::string m_IncludeName;
  46. /**
  47. * The index into the cmMakefile::m_Classes list.
  48. * The index value of -1 indicates that it is not in the list.
  49. */
  50. int m_ClassFileIndex;
  51. /**
  52. * This flag indicates whether dependency checking has been
  53. * performed for this file.
  54. */
  55. bool m_DependDone;
  56. /**
  57. * This method adds the dependencies of another file to this one.
  58. */
  59. void MergeInfo(cmDependInformation*);
  60. /**
  61. * This method removes duplicate depends from the index list.
  62. */
  63. void RemoveDuplicateIndices();
  64. };
  65. // cmMakeDepend is used to generate dependancy information for
  66. // the classes in a makefile
  67. class cmMakeDepend
  68. {
  69. public:
  70. /**
  71. * Construct the object with verbose turned off.
  72. */
  73. cmMakeDepend();
  74. /**
  75. * Destructor.
  76. */
  77. ~cmMakeDepend();
  78. /**
  79. * Set the makefile that is used as a source of classes.
  80. */
  81. void SetMakefile(cmMakefile* makefile);
  82. /**
  83. * Generate the depend information
  84. */
  85. void DoDepends();
  86. /**
  87. * Add a directory to the search path for include files.
  88. */
  89. void AddSearchPath(const char*);
  90. private:
  91. /**
  92. * Add a source file to the search path.
  93. */
  94. void AddFileToSearchPath(const char* filepath);
  95. /**
  96. * Find the index into the m_DependInformation array
  97. * that matches the given m_IncludeName.
  98. */
  99. int FindInformation(const char* includeName);
  100. /**
  101. * Compute the depend information for this class.
  102. */
  103. void Depend(cmDependInformation* info);
  104. /**
  105. * Compute the depend information for this class.
  106. */
  107. void DependWalk(cmDependInformation* info, const char* file);
  108. /**
  109. * Add a dependency. Possibly walk it for more dependencies.
  110. */
  111. void AddDependency(cmDependInformation* info, const char* file);
  112. /**
  113. * Find the full path name for the given file name.
  114. * This uses the include directories.
  115. */
  116. std::string FullPath(const char*);
  117. cmMakefile* m_Makefile;
  118. bool m_Verbose;
  119. cmRegularExpression m_IncludeFileRegularExpression;
  120. typedef std::vector<cmDependInformation*> DependArray;
  121. DependArray m_DependInformation;
  122. std::vector<std::string> m_IncludeDirectories;
  123. };
  124. #endif