1 | // Copyright (C) 2016 The Qt Company Ltd. |
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 |
3 | |
4 | #ifndef MAKEFILEDEPS_H |
5 | #define MAKEFILEDEPS_H |
6 | |
7 | #include <proitems.h> |
8 | |
9 | #include <qfileinfo.h> |
10 | #include <qlist.h> |
11 | #include <qstringlist.h> |
12 | |
13 | QT_BEGIN_NAMESPACE |
14 | |
15 | struct SourceFile; |
16 | struct SourceDependChildren; |
17 | class SourceFiles; |
18 | |
19 | class QMakeLocalFileName |
20 | { |
21 | QString real_name; |
22 | mutable QString local_name; |
23 | public: |
24 | QMakeLocalFileName() = default; |
25 | QMakeLocalFileName(const QString &); |
26 | bool isNull() const { return real_name.isNull(); } |
27 | inline const QString &real() const { return real_name; } |
28 | const QString &local() const; |
29 | |
30 | bool operator==(const QMakeLocalFileName &other) const { |
31 | return (this->real_name == other.real_name); |
32 | } |
33 | bool operator!=(const QMakeLocalFileName &other) const { |
34 | return !(*this == other); |
35 | } |
36 | }; |
37 | |
38 | class QMakeSourceFileInfo |
39 | { |
40 | private: |
41 | //quick project lookups |
42 | SourceFiles *files, *includes; |
43 | bool files_changed; |
44 | QList<QMakeLocalFileName> depdirs; |
45 | QStringList systemIncludes; |
46 | |
47 | //sleezy buffer code |
48 | char *spare_buffer; |
49 | int spare_buffer_size; |
50 | char *getBuffer(int s); |
51 | |
52 | //actual guts |
53 | bool findMocs(SourceFile *); |
54 | bool findDeps(SourceFile *); |
55 | void dependTreeWalker(SourceFile *, SourceDependChildren *); |
56 | |
57 | protected: |
58 | virtual QMakeLocalFileName fixPathForFile(const QMakeLocalFileName &, bool forOpen=false); |
59 | virtual QMakeLocalFileName findFileForDep(const QMakeLocalFileName &, const QMakeLocalFileName &); |
60 | virtual QFileInfo findFileInfo(const QMakeLocalFileName &); |
61 | |
62 | public: |
63 | |
64 | QMakeSourceFileInfo(); |
65 | virtual ~QMakeSourceFileInfo(); |
66 | |
67 | QList<QMakeLocalFileName> dependencyPaths() const { return depdirs; } |
68 | void setDependencyPaths(const QList<QMakeLocalFileName> &); |
69 | |
70 | enum DependencyMode { Recursive, NonRecursive }; |
71 | inline void setDependencyMode(DependencyMode mode) { dep_mode = mode; } |
72 | inline DependencyMode dependencyMode() const { return dep_mode; } |
73 | |
74 | void setSystemIncludes(const ProStringList &list) |
75 | { systemIncludes = list.toQStringList(); } |
76 | |
77 | enum SourceFileType { TYPE_UNKNOWN, TYPE_C, TYPE_UI, TYPE_QRC }; |
78 | enum SourceFileSeek { SEEK_DEPS=0x01, SEEK_MOCS=0x02 }; |
79 | void addSourceFiles(const ProStringList &, uchar seek, SourceFileType type=TYPE_C); |
80 | void addSourceFile(const QString &, uchar seek, SourceFileType type=TYPE_C); |
81 | bool containsSourceFile(const QString &, SourceFileType type=TYPE_C); |
82 | bool isSystemInclude(const QString &); |
83 | |
84 | int included(const QString &file); |
85 | QStringList dependencies(const QString &file); |
86 | |
87 | bool mocable(const QString &file); |
88 | |
89 | private: |
90 | DependencyMode dep_mode; |
91 | }; |
92 | |
93 | QT_END_NAMESPACE |
94 | |
95 | #endif // MAKEFILEDEPS_H |
96 | |