2022-05-10 10:06:48 +00:00
|
|
|
// Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
2011-04-27 10:05:43 +00:00
|
|
|
|
|
|
|
#ifndef PROJECT_H
|
|
|
|
#define PROJECT_H
|
|
|
|
|
2012-09-05 16:29:19 +00:00
|
|
|
#include <qmakeevaluator.h>
|
2011-04-27 10:05:43 +00:00
|
|
|
|
|
|
|
QT_BEGIN_NAMESPACE
|
|
|
|
|
2012-09-05 16:29:19 +00:00
|
|
|
class QMakeProject : private QMakeEvaluator
|
2011-04-27 10:05:43 +00:00
|
|
|
{
|
2012-09-05 16:29:19 +00:00
|
|
|
QString m_projectFile;
|
2015-04-13 19:18:36 +00:00
|
|
|
QString m_projectDir;
|
2011-04-27 10:05:43 +00:00
|
|
|
|
|
|
|
public:
|
2012-09-05 16:29:19 +00:00
|
|
|
QMakeProject();
|
|
|
|
QMakeProject(QMakeProject *p);
|
2011-04-27 10:05:43 +00:00
|
|
|
|
2012-09-05 16:29:19 +00:00
|
|
|
bool read(const QString &project, LoadFlags what = LoadAll);
|
2011-04-27 10:05:43 +00:00
|
|
|
|
2012-09-05 16:29:19 +00:00
|
|
|
QString projectFile() const { return m_projectFile; }
|
2015-04-13 19:18:36 +00:00
|
|
|
QString projectDir() const { return m_projectDir; }
|
2013-12-09 20:46:05 +00:00
|
|
|
QString sourceRoot() const { return m_sourceRoot.isEmpty() ? m_buildRoot : m_sourceRoot; }
|
2012-09-05 16:29:19 +00:00
|
|
|
QString buildRoot() const { return m_buildRoot; }
|
|
|
|
QString confFile() const { return m_conffile; }
|
|
|
|
QString cacheFile() const { return m_cachefile; }
|
2012-09-18 08:54:52 +00:00
|
|
|
QString specDir() const { return m_qmakespec; }
|
2011-04-27 10:05:43 +00:00
|
|
|
|
2012-09-05 16:29:19 +00:00
|
|
|
ProString expand(const QString &v, const QString &file, int line);
|
2012-09-06 10:21:38 +00:00
|
|
|
QStringList expand(const ProKey &func, const QList<ProStringList> &args);
|
2012-08-28 18:53:25 +00:00
|
|
|
bool test(const QString &v, const QString &file, int line)
|
2020-05-30 21:29:21 +00:00
|
|
|
{ m_current.clear(); return evaluateConditional(QStringView(v), file, line) == ReturnTrue; }
|
2012-09-06 10:21:38 +00:00
|
|
|
bool test(const ProKey &func, const QList<ProStringList> &args);
|
2011-04-27 10:05:43 +00:00
|
|
|
|
2019-05-02 16:44:32 +00:00
|
|
|
bool isSet(const ProKey &v) const { return m_valuemapStack.front().contains(v); }
|
2012-09-06 10:21:38 +00:00
|
|
|
bool isEmpty(const ProKey &v) const;
|
2012-09-05 16:29:19 +00:00
|
|
|
ProStringList &values(const ProKey &v) { return valuesRef(v); }
|
2012-09-06 10:21:38 +00:00
|
|
|
int intValue(const ProKey &v, int defaultValue = 0) const;
|
2019-05-02 16:44:32 +00:00
|
|
|
const ProValueMap &variables() const { return m_valuemapStack.front(); }
|
|
|
|
ProValueMap &variables() { return m_valuemapStack.front(); }
|
2016-05-13 13:26:42 +00:00
|
|
|
bool isActiveConfig(const QString &config, bool regex = false)
|
2020-05-30 21:29:21 +00:00
|
|
|
{ return QMakeEvaluator::isActiveConfig(QStringView(config), regex); }
|
2011-04-27 10:05:43 +00:00
|
|
|
|
2012-04-23 17:27:43 +00:00
|
|
|
void dump() const;
|
|
|
|
|
2012-09-05 16:29:19 +00:00
|
|
|
using QMakeEvaluator::LoadFlags;
|
2012-09-19 19:56:16 +00:00
|
|
|
using QMakeEvaluator::VisitReturn;
|
2012-09-05 16:29:19 +00:00
|
|
|
using QMakeEvaluator::setExtraVars;
|
|
|
|
using QMakeEvaluator::setExtraConfigs;
|
|
|
|
using QMakeEvaluator::loadSpec;
|
|
|
|
using QMakeEvaluator::evaluateFeatureFile;
|
|
|
|
using QMakeEvaluator::evaluateConfigFeatures;
|
|
|
|
using QMakeEvaluator::evaluateExpression;
|
2014-11-28 18:47:55 +00:00
|
|
|
using QMakeEvaluator::propertyValue;
|
2012-09-05 16:29:19 +00:00
|
|
|
using QMakeEvaluator::values;
|
|
|
|
using QMakeEvaluator::first;
|
|
|
|
using QMakeEvaluator::isHostBuild;
|
|
|
|
using QMakeEvaluator::dirSep;
|
2012-09-19 19:56:16 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
static bool boolRet(VisitReturn vr);
|
2011-04-27 10:05:43 +00:00
|
|
|
};
|
|
|
|
|
2012-12-17 11:57:13 +00:00
|
|
|
/*!
|
|
|
|
* For variables that are supposed to contain a single int,
|
|
|
|
* this method returns the numeric value.
|
|
|
|
* Only the first value of the variable is taken into account.
|
|
|
|
* The string representation is assumed to look like a C int literal.
|
|
|
|
*/
|
2012-09-06 10:21:38 +00:00
|
|
|
inline int QMakeProject::intValue(const ProKey &v, int defaultValue) const
|
2012-04-16 09:07:02 +00:00
|
|
|
{
|
2012-09-06 10:21:38 +00:00
|
|
|
const ProString &str = first(v);
|
2012-04-16 09:07:02 +00:00
|
|
|
if (!str.isEmpty()) {
|
|
|
|
bool ok;
|
2012-12-17 11:57:13 +00:00
|
|
|
int i = str.toInt(&ok, 0);
|
2012-04-16 09:07:02 +00:00
|
|
|
if (ok)
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
return defaultValue;
|
|
|
|
}
|
|
|
|
|
2011-04-27 10:05:43 +00:00
|
|
|
QT_END_NAMESPACE
|
|
|
|
|
|
|
|
#endif // PROJECT_H
|