1 | /****************************************************************************
|
---|
2 | **
|
---|
3 | ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
---|
4 | ** Contact: Qt Software Information ([email protected])
|
---|
5 | **
|
---|
6 | ** This file is part of the qmake application of the Qt Toolkit.
|
---|
7 | **
|
---|
8 | ** $QT_BEGIN_LICENSE:LGPL$
|
---|
9 | ** Commercial Usage
|
---|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
---|
11 | ** accordance with the Qt Commercial License Agreement provided with the
|
---|
12 | ** Software or, alternatively, in accordance with the terms contained in
|
---|
13 | ** a written agreement between you and Nokia.
|
---|
14 | **
|
---|
15 | ** GNU Lesser General Public License Usage
|
---|
16 | ** Alternatively, this file may be used under the terms of the GNU Lesser
|
---|
17 | ** General Public License version 2.1 as published by the Free Software
|
---|
18 | ** Foundation and appearing in the file LICENSE.LGPL included in the
|
---|
19 | ** packaging of this file. Please review the following information to
|
---|
20 | ** ensure the GNU Lesser General Public License version 2.1 requirements
|
---|
21 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
---|
22 | **
|
---|
23 | ** In addition, as a special exception, Nokia gives you certain
|
---|
24 | ** additional rights. These rights are described in the Nokia Qt LGPL
|
---|
25 | ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
|
---|
26 | ** package.
|
---|
27 | **
|
---|
28 | ** GNU General Public License Usage
|
---|
29 | ** Alternatively, this file may be used under the terms of the GNU
|
---|
30 | ** General Public License version 3.0 as published by the Free Software
|
---|
31 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
---|
32 | ** packaging of this file. Please review the following information to
|
---|
33 | ** ensure the GNU General Public License version 3.0 requirements will be
|
---|
34 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
---|
35 | **
|
---|
36 | ** If you are unsure which license is appropriate for your use, please
|
---|
37 | ** contact the sales department at [email protected].
|
---|
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
|
---|