1
0

cmMakeDepend.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  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 "cmStandardIncludes.h"
  18. #include <cmsys/RegularExpression.hxx>
  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. * Full path not including file name.
  53. */
  54. std::string m_PathOnly;
  55. /**
  56. * Name used to #include this file.
  57. */
  58. std::string m_IncludeName;
  59. /**
  60. * This method adds the dependencies of another file to this one.
  61. */
  62. void AddDependencies(cmDependInformation*);
  63. };
  64. // cmMakeDepend is used to generate dependancy information for
  65. // the classes in a makefile
  66. class cmMakeDepend
  67. {
  68. public:
  69. /**
  70. * Construct the object with verbose turned off.
  71. */
  72. cmMakeDepend();
  73. /**
  74. * Destructor.
  75. */
  76. virtual ~cmMakeDepend();
  77. /**
  78. * Set the makefile that is used as a source of classes.
  79. */
  80. virtual void SetMakefile(const cmMakefile* makefile);
  81. /**
  82. * Get the depend info struct for a source file
  83. */
  84. const cmDependInformation *GetDependInformationForSourceFile(const cmSourceFile &sf) const;
  85. /**
  86. * Add a directory to the search path for include files.
  87. */
  88. virtual void AddSearchPath(const char*);
  89. /**
  90. * Generate dependencies for all the sources of all the targets
  91. * in the makefile.
  92. */
  93. void GenerateMakefileDependencies();
  94. /**
  95. * Generate dependencies for the file given. Returns a pointer to
  96. * the cmDependInformation object for the file.
  97. */
  98. const cmDependInformation* FindDependencies(const char* file);
  99. protected:
  100. /**
  101. * Add a source file to the search path.
  102. */
  103. void AddFileToSearchPath(const char* filepath);
  104. /**
  105. * Compute the depend information for this class.
  106. */
  107. virtual void DependWalk(cmDependInformation* info);
  108. /**
  109. * Add a dependency. Possibly walk it for more dependencies.
  110. */
  111. virtual void AddDependency(cmDependInformation* info, const char* file);
  112. /**
  113. * Fill in the given object with dependency information. If the
  114. * information is already complete, nothing is done.
  115. */
  116. void GenerateDependInformation(cmDependInformation* info);
  117. /**
  118. * Get an instance of cmDependInformation corresponding to the given file
  119. * name.
  120. */
  121. cmDependInformation* GetDependInformation(const char* file, const char *extraPath);
  122. /**
  123. * Find the full path name for the given file name.
  124. * This uses the include directories.
  125. * TODO: Cache path conversions to reduce FileExists calls.
  126. */
  127. std::string FullPath(const char *filename, const char *extraPath);
  128. const cmMakefile* m_Makefile;
  129. bool m_Verbose;
  130. cmsys::RegularExpression m_IncludeFileRegularExpression;
  131. cmsys::RegularExpression m_ComplainFileRegularExpression;
  132. std::vector<std::string> m_IncludeDirectories;
  133. typedef std::map<cmStdString, cmStdString> FileToPathMap;
  134. typedef std::map<cmStdString, FileToPathMap> DirectoryToFileToPathMap;
  135. typedef std::map<cmStdString, cmDependInformation*> DependInformationMap;
  136. DependInformationMap m_DependInformationMap;
  137. DirectoryToFileToPathMap m_DirectoryToFileToPathMap;
  138. };
  139. #endif