cmMakeDepend.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. /*============================================================================
  2. CMake - Cross Platform Makefile Generator
  3. Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
  4. Distributed under the OSI-approved BSD License (the "License");
  5. see accompanying file Copyright.txt for details.
  6. This software is distributed WITHOUT ANY WARRANTY; without even the
  7. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  8. See the License for more information.
  9. ============================================================================*/
  10. #ifndef cmMakeDepend_h
  11. #define cmMakeDepend_h
  12. #include "cmMakefile.h"
  13. #include "cmSourceFile.h"
  14. #include <cmsys/RegularExpression.hxx>
  15. /** \class cmDependInformation
  16. * \brief Store dependency information for a single source file.
  17. *
  18. * This structure stores the depend information for a single source file.
  19. */
  20. class cmDependInformation
  21. {
  22. public:
  23. /**
  24. * Construct with dependency generation marked not done; instance
  25. * not placed in cmMakefile's list.
  26. */
  27. cmDependInformation(): DependDone(false), SourceFile(0) {}
  28. /**
  29. * The set of files on which this one depends.
  30. */
  31. typedef std::set<cmDependInformation*> DependencySetType;
  32. DependencySetType DependencySet;
  33. /**
  34. * This flag indicates whether dependency checking has been
  35. * performed for this file.
  36. */
  37. bool DependDone;
  38. /**
  39. * If this object corresponds to a cmSourceFile instance, this points
  40. * to it.
  41. */
  42. const cmSourceFile *SourceFile;
  43. /**
  44. * Full path to this file.
  45. */
  46. std::string FullPath;
  47. /**
  48. * Full path not including file name.
  49. */
  50. std::string PathOnly;
  51. /**
  52. * Name used to #include this file.
  53. */
  54. std::string 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(cmMakefile* makefile);
  77. /**
  78. * Add a directory to the search path for include files.
  79. */
  80. virtual void AddSearchPath(const char*);
  81. /**
  82. * Generate dependencies for the file given. Returns a pointer to
  83. * the cmDependInformation object for the file.
  84. */
  85. const cmDependInformation* FindDependencies(const char* file);
  86. protected:
  87. /**
  88. * Compute the depend information for this class.
  89. */
  90. virtual void DependWalk(cmDependInformation* info);
  91. /**
  92. * Add a dependency. Possibly walk it for more dependencies.
  93. */
  94. virtual void AddDependency(cmDependInformation* info, const char* file);
  95. /**
  96. * Fill in the given object with dependency information. If the
  97. * information is already complete, nothing is done.
  98. */
  99. void GenerateDependInformation(cmDependInformation* info);
  100. /**
  101. * Get an instance of cmDependInformation corresponding to the given file
  102. * name.
  103. */
  104. cmDependInformation* GetDependInformation(const char* file,
  105. const char *extraPath);
  106. /**
  107. * Find the full path name for the given file name.
  108. * This uses the include directories.
  109. * TODO: Cache path conversions to reduce FileExists calls.
  110. */
  111. std::string FullPath(const char *filename, const char *extraPath);
  112. cmMakefile* Makefile;
  113. bool Verbose;
  114. cmsys::RegularExpression IncludeFileRegularExpression;
  115. cmsys::RegularExpression ComplainFileRegularExpression;
  116. std::vector<std::string> IncludeDirectories;
  117. typedef std::map<cmStdString, cmStdString> FileToPathMapType;
  118. typedef std::map<cmStdString, FileToPathMapType>
  119. DirectoryToFileToPathMapType;
  120. typedef std::map<cmStdString, cmDependInformation*>
  121. DependInformationMapType;
  122. DependInformationMapType DependInformationMap;
  123. DirectoryToFileToPathMapType DirectoryToFileToPathMap;
  124. };
  125. #endif