1 | /****************************************************************************
|
---|
2 | ** $Id: project.h 2 2005-11-16 15:49:26Z dmik $
|
---|
3 | **
|
---|
4 | ** Definition of QMakeProject class.
|
---|
5 | **
|
---|
6 | ** Copyright (C) 1992-2003 Trolltech AS. All rights reserved.
|
---|
7 | **
|
---|
8 | ** This file is part of qmake.
|
---|
9 | **
|
---|
10 | ** This file may be distributed under the terms of the Q Public License
|
---|
11 | ** as defined by Trolltech AS of Norway and appearing in the file
|
---|
12 | ** LICENSE.QPL included in the packaging of this file.
|
---|
13 | **
|
---|
14 | ** This file may be distributed and/or modified under the terms of the
|
---|
15 | ** GNU General Public License version 2 as published by the Free Software
|
---|
16 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
---|
17 | ** packaging of this file.
|
---|
18 | **
|
---|
19 | ** Licensees holding valid Qt Enterprise Edition licenses may use this
|
---|
20 | ** file in accordance with the Qt Commercial License Agreement provided
|
---|
21 | ** with the Software.
|
---|
22 | **
|
---|
23 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
---|
24 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
---|
25 | **
|
---|
26 | ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
|
---|
27 | ** information about Qt Commercial License Agreements.
|
---|
28 | ** See http://www.trolltech.com/qpl/ for QPL licensing information.
|
---|
29 | ** See http://www.trolltech.com/gpl/ for GPL licensing information.
|
---|
30 | **
|
---|
31 | ** Contact info@trolltech.com if any conditions of this licensing are
|
---|
32 | ** not clear to you.
|
---|
33 | **
|
---|
34 | **********************************************************************/
|
---|
35 |
|
---|
36 | #ifndef __PROJECT_H__
|
---|
37 | #define __PROJECT_H__
|
---|
38 |
|
---|
39 | #include <qstringlist.h>
|
---|
40 | #include <qstring.h>
|
---|
41 | #include <qmap.h>
|
---|
42 |
|
---|
43 | class QMakeProperty;
|
---|
44 |
|
---|
45 | class QMakeProject
|
---|
46 | {
|
---|
47 | enum TestStatus { TestNone, TestFound, TestSeek } test_status;
|
---|
48 | int scope_block, scope_flag;
|
---|
49 |
|
---|
50 | QString pfile, cfile;
|
---|
51 | QMakeProperty *prop;
|
---|
52 | void reset();
|
---|
53 | QMap<QString, QStringList> vars, base_vars, cache;
|
---|
54 | bool parse(const QString &text, QMap<QString, QStringList> &place);
|
---|
55 | bool doProjectTest(const QString &func, const QString ¶ms, QMap<QString, QStringList> &place);
|
---|
56 | bool doProjectTest(const QString &func, QStringList args, QMap<QString, QStringList> &place);
|
---|
57 | bool doProjectCheckReqs(const QStringList &deps, QMap<QString, QStringList> &place);
|
---|
58 | QString doVariableReplace(QString &str, const QMap<QString, QStringList> &place);
|
---|
59 |
|
---|
60 | public:
|
---|
61 | QMakeProject();
|
---|
62 | QMakeProject(QMakeProperty *);
|
---|
63 |
|
---|
64 | enum { ReadCache=0x01, ReadConf=0x02, ReadCmdLine=0x04, ReadProFile=0x08, ReadPostFiles=0x10, ReadAll=0xFF };
|
---|
65 | bool read(const QString &project, const QString &pwd, uchar cmd=ReadAll);
|
---|
66 | bool read(uchar cmd=ReadAll);
|
---|
67 |
|
---|
68 | QString projectFile();
|
---|
69 | QString configFile();
|
---|
70 |
|
---|
71 | bool isEmpty(const QString &v);
|
---|
72 | QStringList &values(const QString &v);
|
---|
73 | QString first(const QString &v);
|
---|
74 | QMap<QString, QStringList> &variables();
|
---|
75 | bool isActiveConfig(const QString &x, bool regex=FALSE, QMap<QString, QStringList> *place=NULL);
|
---|
76 |
|
---|
77 | protected:
|
---|
78 | friend class MakefileGenerator;
|
---|
79 | bool read(const QString &file, QMap<QString, QStringList> &place);
|
---|
80 |
|
---|
81 | };
|
---|
82 |
|
---|
83 | inline QString QMakeProject::projectFile()
|
---|
84 | {
|
---|
85 | #if defined(Q_CC_SUN) && (__SUNPRO_CC == 0x500) || defined(Q_CC_HP)
|
---|
86 | // workaround for Sun WorkShop 5.0 bug fixed in Forte 6
|
---|
87 | if (pfile == "-")
|
---|
88 | return QString("(stdin)");
|
---|
89 | else
|
---|
90 | return pfile;
|
---|
91 | #else
|
---|
92 | return pfile == "-" ? QString("(stdin)") : pfile;
|
---|
93 | #endif
|
---|
94 | }
|
---|
95 |
|
---|
96 | inline QString QMakeProject::configFile()
|
---|
97 | { return cfile; }
|
---|
98 |
|
---|
99 | inline bool QMakeProject::isEmpty(const QString &v)
|
---|
100 | { return !vars.contains(v) || vars[v].isEmpty(); }
|
---|
101 |
|
---|
102 | inline QStringList &QMakeProject::values(const QString &v)
|
---|
103 | { return vars[v]; }
|
---|
104 |
|
---|
105 | inline QString QMakeProject::first(const QString &v)
|
---|
106 | {
|
---|
107 | #if defined(Q_CC_SUN) && (__SUNPRO_CC == 0x500) || defined(Q_CC_HP)
|
---|
108 | // workaround for Sun WorkShop 5.0 bug fixed in Forte 6
|
---|
109 | if (isEmpty(v))
|
---|
110 | return QString("");
|
---|
111 | else
|
---|
112 | return vars[v].first();
|
---|
113 | #else
|
---|
114 | return isEmpty(v) ? QString("") : vars[v].first();
|
---|
115 | #endif
|
---|
116 | }
|
---|
117 |
|
---|
118 | inline QMap<QString, QStringList> &QMakeProject::variables()
|
---|
119 | { return vars; }
|
---|
120 |
|
---|
121 | #endif /* __PROJECT_H__ */
|
---|