|
1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
4 ** All rights reserved. |
|
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 ** |
|
7 ** This file is part of the qmake application of the Qt Toolkit. |
|
8 ** |
|
9 ** $QT_BEGIN_LICENSE:LGPL$ |
|
10 ** No Commercial Usage |
|
11 ** This file contains pre-release code and may not be distributed. |
|
12 ** You may use this file in accordance with the terms and conditions |
|
13 ** contained in the Technology Preview License Agreement accompanying |
|
14 ** this package. |
|
15 ** |
|
16 ** GNU Lesser General Public License Usage |
|
17 ** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 ** General Public License version 2.1 as published by the Free Software |
|
19 ** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 ** packaging of this file. Please review the following information to |
|
21 ** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 ** |
|
24 ** In addition, as a special exception, Nokia gives you certain additional |
|
25 ** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 ** |
|
28 ** If you have questions regarding the use of this file, please contact |
|
29 ** Nokia at qt-info@nokia.com. |
|
30 ** |
|
31 ** |
|
32 ** |
|
33 ** |
|
34 ** |
|
35 ** |
|
36 ** |
|
37 ** |
|
38 ** $QT_END_LICENSE$ |
|
39 ** |
|
40 ****************************************************************************/ |
|
41 |
|
42 #ifndef MAKEFILEDEPS_H |
|
43 #define MAKEFILEDEPS_H |
|
44 |
|
45 #include <qstringlist.h> |
|
46 #include <qfileinfo.h> |
|
47 |
|
48 QT_BEGIN_NAMESPACE |
|
49 |
|
50 struct SourceFile; |
|
51 struct SourceDependChildren; |
|
52 class SourceFiles; |
|
53 |
|
54 class QMakeLocalFileName { |
|
55 uint is_null : 1; |
|
56 mutable QString real_name, local_name; |
|
57 public: |
|
58 QMakeLocalFileName() : is_null(1) { } |
|
59 QMakeLocalFileName(const QString &); |
|
60 bool isNull() const { return is_null; } |
|
61 inline const QString &real() const { return real_name; } |
|
62 const QString &local() const; |
|
63 |
|
64 bool operator==(const QMakeLocalFileName &other) { |
|
65 return (this->real_name == other.real_name); |
|
66 } |
|
67 bool operator!=(const QMakeLocalFileName &other) { |
|
68 return !(*this == other); |
|
69 } |
|
70 }; |
|
71 |
|
72 class QMakeSourceFileInfo |
|
73 { |
|
74 private: |
|
75 //quick project lookups |
|
76 SourceFiles *files, *includes; |
|
77 bool files_changed; |
|
78 QList<QMakeLocalFileName> depdirs; |
|
79 |
|
80 //sleezy buffer code |
|
81 char *spare_buffer; |
|
82 int spare_buffer_size; |
|
83 char *getBuffer(int s); |
|
84 |
|
85 //actual guts |
|
86 bool findMocs(SourceFile *); |
|
87 bool findDeps(SourceFile *); |
|
88 void dependTreeWalker(SourceFile *, SourceDependChildren *); |
|
89 |
|
90 //cache |
|
91 QString cachefile; |
|
92 |
|
93 protected: |
|
94 virtual QMakeLocalFileName fixPathForFile(const QMakeLocalFileName &, bool forOpen=false); |
|
95 virtual QMakeLocalFileName findFileForDep(const QMakeLocalFileName &, const QMakeLocalFileName &); |
|
96 virtual QFileInfo findFileInfo(const QMakeLocalFileName &); |
|
97 |
|
98 public: |
|
99 QMakeSourceFileInfo(const QString &cachefile=""); |
|
100 virtual ~QMakeSourceFileInfo(); |
|
101 |
|
102 QList<QMakeLocalFileName> dependencyPaths() const { return depdirs; } |
|
103 void setDependencyPaths(const QList<QMakeLocalFileName> &); |
|
104 |
|
105 enum DependencyMode { Recursive, NonRecursive }; |
|
106 inline void setDependencyMode(DependencyMode mode) { dep_mode = mode; } |
|
107 inline DependencyMode dependencyMode() const { return dep_mode; } |
|
108 |
|
109 enum SourceFileType { TYPE_UNKNOWN, TYPE_C, TYPE_UI, TYPE_QRC }; |
|
110 enum SourceFileSeek { SEEK_DEPS=0x01, SEEK_MOCS=0x02 }; |
|
111 void addSourceFiles(const QStringList &, uchar seek, SourceFileType type=TYPE_C); |
|
112 void addSourceFile(const QString &, uchar seek, SourceFileType type=TYPE_C); |
|
113 bool containsSourceFile(const QString &, SourceFileType type=TYPE_C); |
|
114 |
|
115 int included(const QString &file); |
|
116 QStringList dependencies(const QString &file); |
|
117 |
|
118 bool mocable(const QString &file); |
|
119 |
|
120 virtual QMap<QString, QStringList> getCacheVerification(); |
|
121 virtual bool verifyCache(const QMap<QString, QStringList> &); |
|
122 void setCacheFile(const QString &cachefile); //auto caching |
|
123 void loadCache(const QString &cf); |
|
124 void saveCache(const QString &cf); |
|
125 |
|
126 private: |
|
127 DependencyMode dep_mode; |
|
128 }; |
|
129 |
|
130 QT_END_NAMESPACE |
|
131 |
|
132 #endif // MAKEFILEDEPS_H |