1 /**************************************************************************
3 ** This file is part of Qt Creator
5 ** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
7 ** Contact: Nokia Corporation (qt-info@nokia.com)
11 ** Licensees holding valid Qt Commercial licenses may use this file in
12 ** accordance with the Qt Commercial License Agreement provided with the
13 ** Software or, alternatively, in accordance with the terms contained in
14 ** a written agreement between you and Nokia.
16 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
25 ** If you are unsure which license is appropriate for your use, please
26 ** contact the sales department at http://qt.nokia.com/contact.
28 **************************************************************************/
30 #ifndef PROFILEEVALUATOR_H
31 #define PROFILEEVALUATOR_H
35 #include <QtCore/QHash>
36 #include <QtCore/QStringList>
37 #ifdef PROEVALUATOR_THREAD_SAFE
38 # include <QtCore/QMutex>
39 # include <QtCore/QWaitCondition>
47 class ProFileEvaluatorHandler
50 // qmake/project configuration error
51 virtual void configError(const QString &msg) = 0;
52 // Some error during evaluation
53 virtual void evalError(const QString &filename, int lineNo, const QString &msg) = 0;
54 // error() and message() from .pro file
55 virtual void fileMessage(const QString &msg) = 0;
57 enum EvalFileType { EvalProjectFile, EvalIncludeFile, EvalConfigFile, EvalFeatureFile, EvalAuxFile };
58 virtual void aboutToEval(ProFile *parent, ProFile *proFile, EvalFileType type) = 0;
59 virtual void doneWithEval(ProFile *parent) = 0;
63 class ProFileEvaluator
74 QHash<ProString, FunctionDef> testFunctions;
75 QHash<ProString, FunctionDef> replaceFunctions;
86 // Call this from a concurrency-free context
87 static void initialize();
89 ProFileEvaluator(ProFileOption *option, ProFileParser *parser, ProFileEvaluatorHandler *handler);
92 ProFileEvaluator::TemplateType templateType() const;
93 void setCumulative(bool on); // Default is true!
94 void setOutputDir(const QString &dir); // Default is empty
96 // -nocache, -cache, -spec, QMAKESPEC
97 // -set persistent value
98 void setConfigCommandLineArguments(const QStringList &addUserConfigCmdArgs, const QStringList &removeUserConfigCmdArgs);
99 void setParsePreAndPostFiles(bool on); // Default is true
101 bool accept(ProFile *pro);
103 bool contains(const QString &variableName) const;
104 QString value(const QString &variableName) const;
105 QStringList values(const QString &variableName) const;
106 QStringList values(const QString &variableName, const ProFile *pro) const;
107 QStringList absolutePathValues(const QString &variable, const QString &baseDirectory) const;
108 QStringList absoluteFileValues(
109 const QString &variable, const QString &baseDirectory, const QStringList &searchDirs,
110 const ProFile *pro) const;
111 QString propertyValue(const QString &val) const;
116 friend struct ProFileOption;
119 Q_DECLARE_TYPEINFO(ProFileEvaluator::FunctionDef, Q_MOVABLE_TYPE);
121 // This struct is from qmake, but we are not using everything.
127 //simply global convenience
128 //QString libtool_ext;
129 //QString pkgcfg_ext;
134 //QStringList cpp_ext;
136 //QString cpp_moc_ext;
141 //QString cpp_moc_mod;
148 QHash<QString, QString> properties;
150 enum TARG_MODE { TARG_UNIX_MODE, TARG_WIN_MODE, TARG_MACX_MODE, TARG_MAC9_MODE, TARG_QNX6_MODE };
151 TARG_MODE target_mode;
156 friend class ProFileEvaluator;
157 friend class ProFileEvaluator::Private;
158 QHash<ProString, ProStringList> base_valuemap; // Cached results of qmake.conf, .qmake.cache & default_pre.prf
159 ProFileEvaluator::FunctionDefs base_functions;
160 QStringList feature_roots;
161 QString qmakespec_name;
162 #ifdef PROEVALUATOR_THREAD_SAFE
165 bool base_inProgress;
171 #endif // PROFILEEVALUATOR_H