cmMakeDepend.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. /*=========================================================================
  2. Program: Insight Segmentation & Registration Toolkit
  3. Module: $RCSfile$
  4. Language: C++
  5. Date: $Date$
  6. Version: $Revision$
  7. Copyright (c) 2002 Insight Consortium. All rights reserved.
  8. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
  9. This software is distributed WITHOUT ANY WARRANTY; without even
  10. the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  11. PURPOSE. See the above copyright notices for more information.
  12. =========================================================================*/
  13. #ifndef cmMakeDepend_h
  14. #define cmMakeDepend_h
  15. #include "cmMakefile.h"
  16. #include "cmSourceFile.h"
  17. #include "cmRegularExpression.h"
  18. #include "cmStandardIncludes.h"
  19. /** \class cmDependInformation
  20. * \brief Store dependency information for a single source file.
  21. *
  22. * This structure stores the depend information for a single source file.
  23. */
  24. class cmDependInformation
  25. {
  26. public:
  27. /**
  28. * Construct with dependency generation marked not done; instance
  29. * not placed in cmMakefile's list.
  30. */
  31. cmDependInformation(): m_DependDone(false), m_cmSourceFile(0) {}
  32. /**
  33. * The set of files on which this one depends.
  34. */
  35. typedef std::set<cmDependInformation*> DependencySet;
  36. DependencySet m_DependencySet;
  37. /**
  38. * This flag indicates whether dependency checking has been
  39. * performed for this file.
  40. */
  41. bool m_DependDone;
  42. /**
  43. * If this object corresponds to a cmSourceFile instance, this points
  44. * to it.
  45. */
  46. const cmSourceFile *m_cmSourceFile;
  47. /**
  48. * Full path to this file.
  49. */
  50. std::string m_FullPath;
  51. /**
  52. * Name used to #include this file.
  53. */
  54. std::string m_IncludeName;
  55. /**
  56. * This method adds the dependencies of another file to this one.
  57. */
  58. void AddDependencies(cmDependInformation*);
  59. };
  60. // cmMakeDepend is used to generate dependancy information for
  61. // the classes in a makefile
  62. class cmMakeDepend
  63. {
  64. public:
  65. /**
  66. * Construct the object with verbose turned off.
  67. */
  68. cmMakeDepend();
  69. /**
  70. * Destructor.
  71. */
  72. virtual ~cmMakeDepend();
  73. /**
  74. * Set the makefile that is used as a source of classes.
  75. */
  76. virtual void SetMakefile(const cmMakefile* makefile);
  77. /**
  78. * Get the depend info struct for a source file
  79. */
  80. const cmDependInformation *GetDependInformationForSourceFile(const cmSourceFile &sf) const;
  81. /**
  82. * Add a directory to the search path for include files.
  83. */
  84. virtual void AddSearchPath(const char*);
  85. /**
  86. * Generate dependencies for all the sources of all the targets
  87. * in the makefile.
  88. */
  89. void GenerateMakefileDependencies();
  90. /**
  91. * Generate dependencies for the file given. Returns a pointer to
  92. * the cmDependInformation object for the file.
  93. */
  94. const cmDependInformation* FindDependencies(const char* file);
  95. protected:
  96. /**
  97. * Add a source file to the search path.
  98. */
  99. void AddFileToSearchPath(const char* filepath);
  100. /**
  101. * Compute the depend information for this class.
  102. */
  103. virtual void DependWalk(cmDependInformation* info);
  104. /**
  105. * Add a dependency. Possibly walk it for more dependencies.
  106. */
  107. virtual void AddDependency(cmDependInformation* info, const char* file);
  108. /**
  109. * Fill in the given object with dependency information. If the
  110. * information is already complete, nothing is done.
  111. */
  112. void GenerateDependInformation(cmDependInformation* info);
  113. /**
  114. * Get an instance of cmDependInformation corresponding to the given file
  115. * name.
  116. */
  117. cmDependInformation* GetDependInformation(const char* file, const char *extraPath);
  118. /**
  119. * Find the full path name for the given file name.
  120. * This uses the include directories.
  121. * TODO: Cache path conversions to reduce FileExists calls.
  122. */
  123. std::string FullPath(const char *filename, const char *extraPath);
  124. const cmMakefile* m_Makefile;
  125. bool m_Verbose;
  126. cmRegularExpression m_IncludeFileRegularExpression;
  127. cmRegularExpression m_ComplainFileRegularExpression;
  128. std::vector<std::string> m_IncludeDirectories;
  129. typedef std::map<cmStdString, cmDependInformation*> DependInformationMap;
  130. DependInformationMap m_DependInformationMap;
  131. };
  132. #endif