1 /*============================================================================
2 CMake - Cross Platform Makefile Generator
3 Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
5 Distributed under the OSI-approved BSD License (the "License");
6 see accompanying file Copyright.txt for details.
8 This software is distributed WITHOUT ANY WARRANTY; without even the
9 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10 See the License for more information.
11 ============================================================================*/
15 #include "cmDepends.h"
16 #include <cmsys/RegularExpression.hxx>
20 * \brief Dependency scanner for C and C++ object files.
22 class cmDependsC: public cmDepends
25 /** Checking instances need to know the build directory name and the
26 relative path from the build directory to the target file. */
28 cmDependsC(cmLocalGenerator* lg, const char* targetDir, const char* lang,
29 const std::map<std::string, DependencyVector>* validDeps);
31 /** Virtual destructor to cleanup subclasses properly. */
32 virtual ~cmDependsC();
35 typedef std::vector<char> t_CharBuffer;
37 // Implement writing/checking methods required by superclass.
38 virtual bool WriteDependencies(const char *src,
40 std::ostream& makeDepends,
41 std::ostream& internalDepends);
43 // Method to scan a single file.
44 void Scan(std::istream& is, const char* directory,
45 const cmStdString& fullName);
47 // Regular expression to identify C preprocessor include directives.
48 cmsys::RegularExpression IncludeRegexLine;
50 // Regular expressions to choose which include files to scan
51 // recursively and which to complain about not finding.
52 cmsys::RegularExpression IncludeRegexScan;
53 cmsys::RegularExpression IncludeRegexComplain;
54 std::string IncludeRegexLineString;
55 std::string IncludeRegexScanString;
56 std::string IncludeRegexComplainString;
58 // Regex to transform #include lines.
59 std::string IncludeRegexTransformString;
60 cmsys::RegularExpression IncludeRegexTransform;
61 typedef std::map<cmStdString, cmStdString> TransformRulesType;
62 TransformRulesType TransformRules;
63 void SetupTransforms();
64 void ParseTransform(std::string const& xform);
65 void TransformLine(std::string& line);
68 // Data structures for dependency graph walk.
72 cmStdString QuotedLocation;
77 cmIncludeLines(): Used(false) {}
78 std::vector<UnscannedEntry> UnscannedEntries;
82 const std::map<std::string, DependencyVector>* ValidDeps;
83 std::set<cmStdString> Encountered;
84 std::queue<UnscannedEntry> Unscanned;
87 std::map<cmStdString, cmIncludeLines *> FileCache;
88 std::map<cmStdString, cmStdString> HeaderLocationCache;
90 cmStdString CacheFileName;
92 void WriteCacheFile() const;
95 cmDependsC(cmDependsC const&); // Purposely not implemented.
96 void operator=(cmDependsC const&); // Purposely not implemented.