1 /****************************************************************************
3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: Nokia Corporation (qt-info@nokia.com)
7 ** This file is part of the qmake application of the Qt Toolkit.
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
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.
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.
28 ** If you have questions regarding the use of this file, please contact
29 ** Nokia at qt-info@nokia.com.
40 ****************************************************************************/
45 #include <qstringlist.h>
46 #include <qtextstream.h>
50 #include <qmetatype.h>
64 enum TestStatus
{ TestNone
, TestFound
, TestSeek
};
65 ScopeBlock() : iterate(0), ignore(false), else_status(TestNone
) { }
66 ScopeBlock(bool i
) : iterate(0), ignore(i
), else_status(TestNone
) { }
68 IteratorBlock
*iterate
;
69 uint ignore
: 1, else_status
: 2;
71 friend struct ParsableBlock
;
72 friend struct IteratorBlock
;
73 friend struct FunctionBlock
;
75 QStack
<ScopeBlock
> scope_blocks
;
76 QStack
<FunctionBlock
*> function_blocks
;
77 IteratorBlock
*iterator
;
78 FunctionBlock
*function
;
79 QMap
<QString
, FunctionBlock
*> testFunctions
, replaceFunctions
;
85 QMap
<QString
, QStringList
> vars
, base_vars
, cache
;
86 bool parse(const QString
&text
, QMap
<QString
, QStringList
> &place
, int line_count
=1);
90 IncludeFeatureAlreadyLoaded
,
96 IncludeFlagNone
= 0x00,
97 IncludeFlagFeature
= 0x01,
98 IncludeFlagNewParser
= 0x02,
99 IncludeFlagNewProject
= 0x04
101 IncludeStatus
doProjectInclude(QString file
, uchar flags
, QMap
<QString
, QStringList
> &place
);
103 bool doProjectCheckReqs(const QStringList
&deps
, QMap
<QString
, QStringList
> &place
);
104 bool doVariableReplace(QString
&str
, QMap
<QString
, QStringList
> &place
);
105 QStringList
doVariableReplaceExpand(const QString
&str
, QMap
<QString
, QStringList
> &place
, bool *ok
=0);
106 void init(QMakeProperty
*, const QMap
<QString
, QStringList
> *);
107 QStringList
&values(const QString
&v
, QMap
<QString
, QStringList
> &place
);
110 QMakeProject() { init(0, 0); }
111 QMakeProject(QMakeProperty
*p
) { init(p
, 0); }
112 QMakeProject(QMakeProject
*p
, const QMap
<QString
, QStringList
> *nvars
=0);
113 QMakeProject(const QMap
<QString
, QStringList
> &nvars
) { init(0, &nvars
); }
114 QMakeProject(QMakeProperty
*p
, const QMap
<QString
, QStringList
> &nvars
) { init(p
, &nvars
); }
117 enum { ReadCache
=0x01, ReadConf
=0x02, ReadCmdLine
=0x04, ReadProFile
=0x08,
118 ReadPostFiles
=0x10, ReadFeatures
=0x20, ReadConfigs
=0x40, ReadAll
=0xFF };
119 inline bool parse(const QString
&text
) { return parse(text
, vars
); }
120 bool read(const QString
&project
, uchar cmd
=ReadAll
);
121 bool read(uchar cmd
=ReadAll
);
123 QStringList
userExpandFunctions() { return replaceFunctions
.keys(); }
124 QStringList
userTestFunctions() { return testFunctions
.keys(); }
126 QString
projectFile();
127 QString
configFile();
128 inline QMakeProperty
*properties() { return prop
; }
130 bool doProjectTest(QString str
, QMap
<QString
, QStringList
> &place
);
131 bool doProjectTest(QString func
, const QString
¶ms
,
132 QMap
<QString
, QStringList
> &place
);
133 bool doProjectTest(QString func
, QStringList args
,
134 QMap
<QString
, QStringList
> &place
);
135 bool doProjectTest(QString func
, QList
<QStringList
> args
,
136 QMap
<QString
, QStringList
> &place
);
137 QStringList
doProjectExpand(QString func
, const QString
¶ms
,
138 QMap
<QString
, QStringList
> &place
);
139 QStringList
doProjectExpand(QString func
, QStringList args
,
140 QMap
<QString
, QStringList
> &place
);
141 QStringList
doProjectExpand(QString func
, QList
<QStringList
> args
,
142 QMap
<QString
, QStringList
> &place
);
144 QStringList
expand(const QString
&v
);
145 QStringList
expand(const QString
&func
, const QList
<QStringList
> &args
);
146 bool test(const QString
&v
);
147 bool test(const QString
&func
, const QList
<QStringList
> &args
);
148 bool isActiveConfig(const QString
&x
, bool regex
=false,
149 QMap
<QString
, QStringList
> *place
=NULL
);
151 bool isSet(const QString
&v
);
152 bool isEmpty(const QString
&v
);
153 QStringList
&values(const QString
&v
);
154 QString
first(const QString
&v
);
155 QMap
<QString
, QStringList
> &variables();
158 friend class MakefileGenerator
;
159 bool read(const QString
&file
, QMap
<QString
, QStringList
> &place
);
160 bool read(QTextStream
&file
, QMap
<QString
, QStringList
> &place
);
163 Q_DECLARE_METATYPE(QMakeProject
*)
165 inline QString
QMakeProject::projectFile()
168 return QString("(stdin)");
172 inline QString
QMakeProject::configFile()
175 inline QStringList
&QMakeProject::values(const QString
&v
)
176 { return values(v
, vars
); }
178 inline bool QMakeProject::isEmpty(const QString
&v
)
179 { return !isSet(v
) || values(v
).isEmpty(); }
181 inline bool QMakeProject::isSet(const QString
&v
)
182 { return vars
.contains(v
); }
184 inline QString
QMakeProject::first(const QString
&v
)
186 const QStringList vals
= values(v
);
192 inline QMap
<QString
, QStringList
> &QMakeProject::variables()
195 // Helper functions needed for Symbian
197 bool isForSymbianSbsv2();