cmMakeDepend.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  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. * Set a regular expression that include files must match
  88. * in order to be considered as part of the depend information.
  89. */
  90. void SetIncludeRegularExpression(const char* regex);
  91. /**
  92. * Add a directory to the search path for include files.
  93. */
  94. void AddSearchPath(const char*);
  95. private:
  96. /**
  97. * Add a source file to the search path.
  98. */
  99. void AddFileToSearchPath(const char* filepath);
  100. /**
  101. * Find the index into the m_DependInformation array
  102. * that matches the given m_IncludeName.
  103. */
  104. int FindInformation(const char* includeName);
  105. /**
  106. * Compute the depend information for this class.
  107. */
  108. void Depend(cmDependInformation* info);
  109. /**
  110. * Find the full path name for the given file name.
  111. * This uses the include directories.
  112. */
  113. std::string FullPath(const char*);
  114. cmMakefile* m_Makefile;
  115. bool m_Verbose;
  116. cmRegularExpression m_IncludeFileRegularExpression;
  117. typedef std::vector<cmDependInformation*> DependArray;
  118. DependArray m_DependInformation;
  119. std::vector<std::string> m_IncludeDirectories;
  120. };
  121. #endif