cmDependsC.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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 cmDependsC_h
  14. #define cmDependsC_h
  15. #include "cmDepends.h"
  16. #include <cmsys/RegularExpression.hxx>
  17. #include <queue>
  18. /** \class cmDependsC
  19. * \brief Dependency scanner for C and C++ object files.
  20. */
  21. class cmDependsC: public cmDepends
  22. {
  23. public:
  24. /** Checking instances need to know the build directory name and the
  25. relative path from the build directory to the target file. */
  26. cmDependsC();
  27. cmDependsC(std::vector<std::string> const& includes,
  28. const char* scanRegex, const char* complainRegex,
  29. std::set<cmStdString> const& generatedFiles, const cmStdString& cachFileName);
  30. /** Virtual destructor to cleanup subclasses properly. */
  31. virtual ~cmDependsC();
  32. protected:
  33. typedef std::vector<char> t_CharBuffer;
  34. // Implement writing/checking methods required by superclass.
  35. virtual bool WriteDependencies(const char *src,
  36. const char *file,
  37. std::ostream& makeDepends,
  38. std::ostream& internalDepends);
  39. // Method to scan a single file.
  40. void Scan(std::istream& is, const char* directory, const cmStdString& fullName);
  41. // Method to test for the existence of a file.
  42. bool FileExistsOrIsGenerated(const std::string& fname,
  43. std::set<cmStdString>& scanned,
  44. std::set<cmStdString>& dependencies);
  45. // The include file search path.
  46. std::vector<std::string> const* m_IncludePath;
  47. // Regular expression to identify C preprocessor include directives.
  48. cmsys::RegularExpression m_IncludeRegexLine;
  49. // Regular expressions to choose which include files to scan
  50. // recursively and which to complain about not finding.
  51. cmsys::RegularExpression m_IncludeRegexScan;
  52. cmsys::RegularExpression m_IncludeRegexComplain;
  53. // Set of generated files available.
  54. std::set<cmStdString> const* m_GeneratedFiles;
  55. // Data structures for dependency graph walk.
  56. struct UnscannedEntry
  57. {
  58. cmStdString FileName;
  59. cmStdString QuotedLocation;
  60. };
  61. struct cmIncludeLines
  62. {
  63. cmIncludeLines(): m_Used(false) {}
  64. std::list<UnscannedEntry> m_UnscannedEntries;
  65. bool m_Used;
  66. };
  67. std::set<cmStdString> m_Encountered;
  68. std::queue<UnscannedEntry> m_Unscanned;
  69. t_CharBuffer m_Buffer;
  70. std::map<cmStdString, cmIncludeLines *> m_fileCache;
  71. cmStdString m_cacheFileName;
  72. void WriteCacheFile() const;
  73. void ReadCacheFile();
  74. private:
  75. cmDependsC(cmDependsC const&); // Purposely not implemented.
  76. void operator=(cmDependsC const&); // Purposely not implemented.
  77. };
  78. #endif