cmMakeDepend.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. /*=========================================================================
  2. Program: CMake - Cross-Platform Makefile Generator
  3. Module: $RCSfile$
  4. Language: C++
  5. Date: $Date$
  6. Version: $Revision$
  7. Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
  8. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html 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 <cmsys/RegularExpression.hxx>
  18. /** \class cmDependInformation
  19. * \brief Store dependency information for a single source file.
  20. *
  21. * This structure stores the depend information for a single source file.
  22. */
  23. class cmDependInformation
  24. {
  25. public:
  26. /**
  27. * Construct with dependency generation marked not done; instance
  28. * not placed in cmMakefile's list.
  29. */
  30. cmDependInformation(): m_DependDone(false), m_cmSourceFile(0) {}
  31. /**
  32. * The set of files on which this one depends.
  33. */
  34. typedef std::set<cmDependInformation*> DependencySet;
  35. DependencySet m_DependencySet;
  36. /**
  37. * This flag indicates whether dependency checking has been
  38. * performed for this file.
  39. */
  40. bool m_DependDone;
  41. /**
  42. * If this object corresponds to a cmSourceFile instance, this points
  43. * to it.
  44. */
  45. const cmSourceFile *m_cmSourceFile;
  46. /**
  47. * Full path to this file.
  48. */
  49. std::string m_FullPath;
  50. /**
  51. * Full path not including file name.
  52. */
  53. std::string m_PathOnly;
  54. /**
  55. * Name used to #include this file.
  56. */
  57. std::string m_IncludeName;
  58. /**
  59. * This method adds the dependencies of another file to this one.
  60. */
  61. void AddDependencies(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. virtual ~cmMakeDepend();
  76. /**
  77. * Set the makefile that is used as a source of classes.
  78. */
  79. virtual void SetMakefile(const cmMakefile* makefile);
  80. /**
  81. * Get the depend info struct for a source file
  82. */
  83. const cmDependInformation *GetDependInformationForSourceFile(const cmSourceFile &sf) const;
  84. /**
  85. * Add a directory to the search path for include files.
  86. */
  87. virtual void AddSearchPath(const char*);
  88. /**
  89. * Generate dependencies for all the sources of all the targets
  90. * in the makefile.
  91. */
  92. void GenerateMakefileDependencies();
  93. /**
  94. * Generate dependencies for the file given. Returns a pointer to
  95. * the cmDependInformation object for the file.
  96. */
  97. const cmDependInformation* FindDependencies(const char* file);
  98. protected:
  99. /**
  100. * Add a source file to the search path.
  101. */
  102. void AddFileToSearchPath(const char* filepath);
  103. /**
  104. * Compute the depend information for this class.
  105. */
  106. virtual void DependWalk(cmDependInformation* info);
  107. /**
  108. * Add a dependency. Possibly walk it for more dependencies.
  109. */
  110. virtual void AddDependency(cmDependInformation* info, const char* file);
  111. /**
  112. * Fill in the given object with dependency information. If the
  113. * information is already complete, nothing is done.
  114. */
  115. void GenerateDependInformation(cmDependInformation* info);
  116. /**
  117. * Get an instance of cmDependInformation corresponding to the given file
  118. * name.
  119. */
  120. cmDependInformation* GetDependInformation(const char* file, const char *extraPath);
  121. /**
  122. * Find the full path name for the given file name.
  123. * This uses the include directories.
  124. * TODO: Cache path conversions to reduce FileExists calls.
  125. */
  126. std::string FullPath(const char *filename, const char *extraPath);
  127. const cmMakefile* m_Makefile;
  128. bool m_Verbose;
  129. cmsys::RegularExpression m_IncludeFileRegularExpression;
  130. cmsys::RegularExpression m_ComplainFileRegularExpression;
  131. std::vector<std::string> m_IncludeDirectories;
  132. typedef std::map<cmStdString, cmStdString> FileToPathMap;
  133. typedef std::map<cmStdString, FileToPathMap> DirectoryToFileToPathMap;
  134. typedef std::map<cmStdString, cmDependInformation*> DependInformationMap;
  135. DependInformationMap m_DependInformationMap;
  136. DirectoryToFileToPathMap m_DirectoryToFileToPathMap;
  137. };
  138. #endif