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 // Implement writing/checking methods required by superclass.
36 virtual bool WriteDependencies(const std::set<std::string>& sources,
37 const std::string& obj,
38 std::ostream& makeDepends,
39 std::ostream& internalDepends);
41 // Method to scan a single file.
42 void Scan(std::istream& is, const char* directory,
43 const cmStdString& fullName);
45 // Regular expression to identify C preprocessor include directives.
46 cmsys::RegularExpression IncludeRegexLine;
48 // Regular expressions to choose which include files to scan
49 // recursively and which to complain about not finding.
50 cmsys::RegularExpression IncludeRegexScan;
51 cmsys::RegularExpression IncludeRegexComplain;
52 std::string IncludeRegexLineString;
53 std::string IncludeRegexScanString;
54 std::string IncludeRegexComplainString;
56 // Regex to transform #include lines.
57 std::string IncludeRegexTransformString;
58 cmsys::RegularExpression IncludeRegexTransform;
59 typedef std::map<cmStdString, cmStdString> TransformRulesType;
60 TransformRulesType TransformRules;
61 void SetupTransforms();
62 void ParseTransform(std::string const& xform);
63 void TransformLine(std::string& line);
66 // Data structures for dependency graph walk.
70 cmStdString QuotedLocation;
75 cmIncludeLines(): Used(false) {}
76 std::vector<UnscannedEntry> UnscannedEntries;
80 const std::map<std::string, DependencyVector>* ValidDeps;
81 std::set<cmStdString> Encountered;
82 std::queue<UnscannedEntry> Unscanned;
84 std::map<cmStdString, cmIncludeLines *> FileCache;
85 std::map<cmStdString, cmStdString> HeaderLocationCache;
87 cmStdString CacheFileName;
89 void WriteCacheFile() const;
92 cmDependsC(cmDependsC const&); // Purposely not implemented.
93 void operator=(cmDependsC const&); // Purposely not implemented.