1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmDependsC.h,v $
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 =========================================================================*/
20 #include "cmDepends.h"
21 #include <cmsys/RegularExpression.hxx>
25 * \brief Dependency scanner for C and C++ object files.
27 class cmDependsC
: public cmDepends
30 /** Checking instances need to know the build directory name and the
31 relative path from the build directory to the target file. */
33 cmDependsC(cmLocalGenerator
* lg
, const char* targetDir
, const char* lang
);
35 /** Virtual destructor to cleanup subclasses properly. */
36 virtual ~cmDependsC();
39 typedef std::vector
<char> t_CharBuffer
;
41 // Implement writing/checking methods required by superclass.
42 virtual bool WriteDependencies(const char *src
,
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
);
72 // Data structures for dependency graph walk.
76 cmStdString QuotedLocation
;
81 cmIncludeLines(): Used(false) {}
82 std::vector
<UnscannedEntry
> UnscannedEntries
;
86 std::set
<cmStdString
> Encountered
;
87 std::queue
<UnscannedEntry
> Unscanned
;
90 std::map
<cmStdString
, cmIncludeLines
*> FileCache
;
91 std::map
<cmStdString
, cmStdString
> HeaderLocationCache
;
93 cmStdString CacheFileName
;
95 void WriteCacheFile() const;
98 cmDependsC(cmDependsC
const&); // Purposely not implemented.
99 void operator=(cmDependsC
const&); // Purposely not implemented.