cmMakeDepend.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /*=========================================================================
  2. Program: Insight Segmentation & Registration Toolkit
  3. Module: $RCSfile$
  4. Language: C++
  5. Date: $Date$
  6. Version: $Revision$
  7. Copyright (c) 2000 National Library of Medicine
  8. All rights reserved.
  9. See COPYRIGHT.txt for copyright details.
  10. =========================================================================*/
  11. /**
  12. * cmMakeDepend
  13. */
  14. #ifndef cmMakeDepend_h
  15. #define cmMakeDepend_h
  16. #include "cmMakefile.h"
  17. #include "cmClassFile.h"
  18. #include "cmRegularExpression.h"
  19. #include <vector>
  20. #include <string>
  21. // This structure stores the depend information
  22. // for a single source file
  23. struct cmDependInformation
  24. {
  25. cmDependInformation()
  26. {
  27. m_DependDone = false;
  28. m_ClassFileIndex = -1;
  29. }
  30. // index into m_DependInformation array of cmMakeDepend
  31. // class, represents the files that this file depends on
  32. std::vector<int> m_Indices;
  33. // full path to file
  34. std::string m_FullPath;
  35. // name as include directive uses
  36. std::string m_IncludeName;
  37. // refers back to the index of the cmMakefile's array
  38. // of cmClassFile objects which this class class describes,
  39. // -1 for files not in the array
  40. int m_ClassFileIndex;
  41. // flag to determine if depends have
  42. // been done for this file
  43. bool m_DependDone;
  44. // function to add the depends of another file to this one
  45. void MergeInfo(cmDependInformation*);
  46. // remove duplicate depends from the index list
  47. void RemoveDuplicateIndices();
  48. };
  49. // cmMakeDepend is used to generate dependancy information for
  50. // the classes in a makefile
  51. class cmMakeDepend
  52. {
  53. public:
  54. cmMakeDepend();
  55. ~cmMakeDepend();
  56. /**
  57. * Set the makefile that is used as a source of classes.
  58. */
  59. void SetMakefile(cmMakefile* makefile);
  60. /**
  61. * Generate the depend information
  62. */
  63. void DoDepends();
  64. /**
  65. * Set a regular expression that include files must match
  66. * in order to be considered as part of the depend information
  67. */
  68. void SetIncludeRegularExpression(const char* regex);
  69. /**
  70. * Add a directory to the search path for include files
  71. */
  72. void AddSearchPath(const char*);
  73. private:
  74. void AddFileToSearchPath(const char* filepath);
  75. /**
  76. * Find the index into the m_DependInformation array
  77. * that matches the given m_IncludeName
  78. */
  79. int FindInformation(const char* includeName);
  80. /**
  81. * Compute the depend information for this class
  82. */
  83. void Depend(cmDependInformation* info);
  84. /**
  85. * Find the full path name for the given file name.
  86. * This uses the include directories
  87. */
  88. std::string FullPath(const char*);
  89. private:
  90. cmMakefile* m_Makefile;
  91. bool m_Verbose;
  92. cmRegularExpression m_IncludeFileRegularExpression;
  93. typedef std::vector<cmDependInformation*> DependArray;
  94. DependArray m_DependInformation;
  95. std::vector<std::string> m_IncludeDirectories;
  96. };
  97. #endif