forked from qt-creator/qt-creator
qmake: make QMakeEvaluator::isActiveConfig() take a QStringRef argument
saves some more cheap but pointless conversions to QString. this makes the introduction of the ProStringList::contains(QStringRef) overload necessary. Change-Id: Ic61993bd9a4b28fbba1b8e346345fd5f5636c6f0 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> (cherry picked from qtbase/11d957d04381c7162dd5621c61f9963580ec7041) (cherry picked from qtbase/9f98935d33cc15c938be2b9295ba2fbe4edb0ee0) Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
@@ -196,13 +196,15 @@ QVector<ProFileEvaluator::SourceFile> ProFileEvaluator::absoluteFileValues(
|
||||
|
||||
ProFileEvaluator::TemplateType ProFileEvaluator::templateType() const
|
||||
{
|
||||
static QString str_staticlib = QStringLiteral("staticlib");
|
||||
|
||||
const ProStringList &templ = d->values(ProKey("TEMPLATE"));
|
||||
if (templ.count() >= 1) {
|
||||
const QString &t = templ.at(0).toQString();
|
||||
if (!t.compare(QLatin1String("app"), Qt::CaseInsensitive))
|
||||
return TT_Application;
|
||||
if (!t.compare(QLatin1String("lib"), Qt::CaseInsensitive))
|
||||
return d->isActiveConfig(QStringLiteral("staticlib")) ? TT_StaticLibrary : TT_SharedLibrary;
|
||||
return d->isActiveConfig(QStringRef(&str_staticlib)) ? TT_StaticLibrary : TT_SharedLibrary;
|
||||
if (!t.compare(QLatin1String("script"), Qt::CaseInsensitive))
|
||||
return TT_Script;
|
||||
if (!t.compare(QLatin1String("aux"), Qt::CaseInsensitive))
|
||||
@@ -224,6 +226,10 @@ bool ProFileEvaluator::loadNamedSpec(const QString &specDir, bool hostSpec)
|
||||
|
||||
bool ProFileEvaluator::accept(ProFile *pro, QMakeEvaluator::LoadFlags flags)
|
||||
{
|
||||
static QString str_no_include_pwd = QStringLiteral("no_include_pwd");
|
||||
static QString str_plugin = QStringLiteral("plugin");
|
||||
static QString str_plugin_no_share_shlib_cflags = QStringLiteral("plugin_no_share_shlib_cflags");
|
||||
|
||||
if (d->visitProFile(pro, QMakeHandler::EvalProjectFile, flags) != QMakeEvaluator::ReturnTrue)
|
||||
return false;
|
||||
|
||||
@@ -232,7 +238,7 @@ bool ProFileEvaluator::accept(ProFile *pro, QMakeEvaluator::LoadFlags flags)
|
||||
|
||||
ProStringList &incpath = d->valuesRef(ProKey("INCLUDEPATH"));
|
||||
incpath += d->values(ProKey("QMAKE_INCDIR"));
|
||||
if (!d->isActiveConfig(QStringLiteral("no_include_pwd"))) {
|
||||
if (!d->isActiveConfig(QStringRef(&str_no_include_pwd))) {
|
||||
incpath.prepend(ProString(pro->directoryName()));
|
||||
// It's pretty stupid that this is appended - it should be the second entry.
|
||||
if (pro->directoryName() != d->m_outputDir)
|
||||
@@ -249,8 +255,8 @@ bool ProFileEvaluator::accept(ProFile *pro, QMakeEvaluator::LoadFlags flags)
|
||||
break;
|
||||
case TT_SharedLibrary:
|
||||
{
|
||||
bool plugin = d->isActiveConfig(QStringLiteral("plugin"));
|
||||
if (!plugin || !d->isActiveConfig(QStringLiteral("plugin_no_share_shlib_cflags")))
|
||||
bool plugin = d->isActiveConfig(QStringRef(&str_plugin));
|
||||
if (!plugin || !d->isActiveConfig(QStringRef(&str_plugin_no_share_shlib_cflags)))
|
||||
cxxflags += d->values(ProKey("QMAKE_CXXFLAGS_SHLIB"));
|
||||
if (plugin)
|
||||
cxxflags += d->values(ProKey("QMAKE_CXXFLAGS_PLUGIN"));
|
||||
|
@@ -458,6 +458,14 @@ bool ProStringList::contains(const ProString &str, Qt::CaseSensitivity cs) const
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ProStringList::contains(const QStringRef &str, Qt::CaseSensitivity cs) const
|
||||
{
|
||||
for (int i = 0; i < size(); i++)
|
||||
if (!at(i).toQStringRef().compare(str, cs))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ProStringList::contains(const char *str, Qt::CaseSensitivity cs) const
|
||||
{
|
||||
for (int i = 0; i < size(); i++)
|
||||
|
@@ -244,6 +244,7 @@ public:
|
||||
void removeDuplicates();
|
||||
|
||||
bool contains(const ProString &str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
|
||||
bool contains(const QStringRef &str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
|
||||
bool contains(const QString &str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
|
||||
{ return contains(ProString(str), cs); }
|
||||
bool contains(const char *str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
|
||||
|
@@ -1447,7 +1447,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinConditional(
|
||||
return ReturnFalse;
|
||||
}
|
||||
if (args.count() == 1)
|
||||
return returnBool(isActiveConfig(args.at(0).toQString(m_tmp2)));
|
||||
return returnBool(isActiveConfig(args.at(0).toQStringRef()));
|
||||
const QStringList &mutuals = args.at(1).toQString(m_tmp2).split(QLatin1Char('|'));
|
||||
const ProStringList &configs = values(statics.strCONFIG);
|
||||
|
||||
|
@@ -645,7 +645,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::visitProBlock(
|
||||
evalError(fL1S("Conditional must expand to exactly one word."));
|
||||
okey = false;
|
||||
} else {
|
||||
okey = isActiveConfig(curr.at(0).toQString(m_tmp2), true);
|
||||
okey = isActiveConfig(curr.at(0).toQStringRef(), true);
|
||||
traceMsg("condition %s is %s", dbgStr(curr.at(0)), dbgBool(okey));
|
||||
okey ^= invert;
|
||||
}
|
||||
@@ -1621,7 +1621,7 @@ QString QMakeEvaluator::currentDirectory() const
|
||||
return QString();
|
||||
}
|
||||
|
||||
bool QMakeEvaluator::isActiveConfig(const QString &config, bool regex)
|
||||
bool QMakeEvaluator::isActiveConfig(const QStringRef &config, bool regex)
|
||||
{
|
||||
// magic types for easy flipping
|
||||
if (config == statics.strtrue)
|
||||
@@ -1633,9 +1633,7 @@ bool QMakeEvaluator::isActiveConfig(const QString &config, bool regex)
|
||||
return m_hostBuild;
|
||||
|
||||
if (regex && (config.contains(QLatin1Char('*')) || config.contains(QLatin1Char('?')))) {
|
||||
QString cfg = config;
|
||||
cfg.detach(); // Keep m_tmp out of QRegExp's cache
|
||||
QRegExp re(cfg, Qt::CaseSensitive, QRegExp::Wildcard);
|
||||
QRegExp re(config.toString(), Qt::CaseSensitive, QRegExp::Wildcard);
|
||||
|
||||
// mkspecs
|
||||
if (re.exactMatch(m_qmakespecName))
|
||||
@@ -1655,7 +1653,7 @@ bool QMakeEvaluator::isActiveConfig(const QString &config, bool regex)
|
||||
return true;
|
||||
|
||||
// CONFIG variable
|
||||
if (values(statics.strCONFIG).contains(ProString(config)))
|
||||
if (values(statics.strCONFIG).contains(config))
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@@ -220,7 +220,7 @@ public:
|
||||
void updateMkspecPaths();
|
||||
void updateFeaturePaths();
|
||||
|
||||
bool isActiveConfig(const QString &config, bool regex = false);
|
||||
bool isActiveConfig(const QStringRef &config, bool regex = false);
|
||||
|
||||
void populateDeps(
|
||||
const ProStringList &deps, const ProString &prefix, const ProStringList &suffixes,
|
||||
|
Reference in New Issue
Block a user