cmMakeDepend.h 3.3 KB

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