cmMakeDepend.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  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(): DependDone(false), SourceFile(0) {}
  31. /**
  32. * The set of files on which this one depends.
  33. */
  34. typedef std::set<cmDependInformation*> DependencySetType;
  35. DependencySetType DependencySet;
  36. /**
  37. * This flag indicates whether dependency checking has been
  38. * performed for this file.
  39. */
  40. bool DependDone;
  41. /**
  42. * If this object corresponds to a cmSourceFile instance, this points
  43. * to it.
  44. */
  45. const cmSourceFile *SourceFile;
  46. /**
  47. * Full path to this file.
  48. */
  49. std::string FullPath;
  50. /**
  51. * Full path not including file name.
  52. */
  53. std::string PathOnly;
  54. /**
  55. * Name used to #include this file.
  56. */
  57. std::string 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(cmMakefile* makefile);
  80. /**
  81. * Add a directory to the search path for include files.
  82. */
  83. virtual void AddSearchPath(const char*);
  84. /**
  85. * Generate dependencies for the file given. Returns a pointer to
  86. * the cmDependInformation object for the file.
  87. */
  88. const cmDependInformation* FindDependencies(const char* file);
  89. protected:
  90. /**
  91. * Compute the depend information for this class.
  92. */
  93. virtual void DependWalk(cmDependInformation* info);
  94. /**
  95. * Add a dependency. Possibly walk it for more dependencies.
  96. */
  97. virtual void AddDependency(cmDependInformation* info, const char* file);
  98. /**
  99. * Fill in the given object with dependency information. If the
  100. * information is already complete, nothing is done.
  101. */
  102. void GenerateDependInformation(cmDependInformation* info);
  103. /**
  104. * Get an instance of cmDependInformation corresponding to the given file
  105. * name.
  106. */
  107. cmDependInformation* GetDependInformation(const char* file,
  108. const char *extraPath);
  109. /**
  110. * Find the full path name for the given file name.
  111. * This uses the include directories.
  112. * TODO: Cache path conversions to reduce FileExists calls.
  113. */
  114. std::string FullPath(const char *filename, const char *extraPath);
  115. cmMakefile* Makefile;
  116. bool Verbose;
  117. cmsys::RegularExpression IncludeFileRegularExpression;
  118. cmsys::RegularExpression ComplainFileRegularExpression;
  119. std::vector<std::string> IncludeDirectories;
  120. typedef std::map<cmStdString, cmStdString> FileToPathMapType;
  121. typedef std::map<cmStdString, FileToPathMapType>
  122. DirectoryToFileToPathMapType;
  123. typedef std::map<cmStdString, cmDependInformation*>
  124. DependInformationMapType;
  125. DependInformationMapType DependInformationMap;
  126. DirectoryToFileToPathMapType DirectoryToFileToPathMap;
  127. };
  128. #endif