Resync
[CMakeLuaTailorHgBridge.git] / CMakeLua / Source / cmDependsC.h
blob2f5031e511b52ba2bad2de344c37cc95ccd56637
1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmDependsC.h,v $
5 Language: C++
6 Date: $Date: 2008-05-14 15:54:32 $
7 Version: $Revision: 1.22 $
9 Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
10 See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
12 This software is distributed WITHOUT ANY WARRANTY; without even
13 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 PURPOSE. See the above copyright notices for more information.
16 =========================================================================*/
17 #ifndef cmDependsC_h
18 #define cmDependsC_h
20 #include "cmDepends.h"
21 #include <cmsys/RegularExpression.hxx>
22 #include <queue>
24 /** \class cmDependsC
25 * \brief Dependency scanner for C and C++ object files.
27 class cmDependsC: public cmDepends
29 public:
30 /** Checking instances need to know the build directory name and the
31 relative path from the build directory to the target file. */
32 cmDependsC();
33 cmDependsC(cmLocalGenerator* lg, const char* targetDir, const char* lang);
35 /** Virtual destructor to cleanup subclasses properly. */
36 virtual ~cmDependsC();
38 protected:
39 typedef std::vector<char> t_CharBuffer;
41 // Implement writing/checking methods required by superclass.
42 virtual bool WriteDependencies(const char *src,
43 const char *file,
44 std::ostream& makeDepends,
45 std::ostream& internalDepends);
47 // Method to scan a single file.
48 void Scan(std::istream& is, const char* directory,
49 const cmStdString& fullName);
51 // Regular expression to identify C preprocessor include directives.
52 cmsys::RegularExpression IncludeRegexLine;
54 // Regular expressions to choose which include files to scan
55 // recursively and which to complain about not finding.
56 cmsys::RegularExpression IncludeRegexScan;
57 cmsys::RegularExpression IncludeRegexComplain;
58 std::string IncludeRegexLineString;
59 std::string IncludeRegexScanString;
60 std::string IncludeRegexComplainString;
62 // Regex to transform #include lines.
63 std::string IncludeRegexTransformString;
64 cmsys::RegularExpression IncludeRegexTransform;
65 typedef std::map<cmStdString, cmStdString> TransformRulesType;
66 TransformRulesType TransformRules;
67 void SetupTransforms();
68 void ParseTransform(std::string const& xform);
69 void TransformLine(std::string& line);
71 public:
72 // Data structures for dependency graph walk.
73 struct UnscannedEntry
75 cmStdString FileName;
76 cmStdString QuotedLocation;
79 struct cmIncludeLines
81 cmIncludeLines(): Used(false) {}
82 std::vector<UnscannedEntry> UnscannedEntries;
83 bool Used;
85 protected:
86 std::set<cmStdString> Encountered;
87 std::queue<UnscannedEntry> Unscanned;
88 t_CharBuffer Buffer;
90 std::map<cmStdString, cmIncludeLines *> FileCache;
91 std::map<cmStdString, cmStdString> HeaderLocationCache;
93 cmStdString CacheFileName;
95 void WriteCacheFile() const;
96 void ReadCacheFile();
97 private:
98 cmDependsC(cmDependsC const&); // Purposely not implemented.
99 void operator=(cmDependsC const&); // Purposely not implemented.
102 #endif