Commit 16286b76 authored by Aaron McCarthy's avatar Aaron McCarthy
Browse files

Support condition scopes in pro files.

The CONFIG variable was not being checked when testing conditional
scopes. Resulting in, for example, incorrect executable paths when
those paths depend on a particular CONFIG value being set.
parent 981b1354
......@@ -1297,10 +1297,28 @@ bool ProFileEvaluator::Private::isActiveConfig(const QString &config, bool regex
if (Option::target_mode == Option::TARG_WIN_MODE && config == QLatin1String("win32"))
return true;
QRegExp re(config, Qt::CaseSensitive, QRegExp::Wildcard);
QString spec = Option::qmakespec;
if ((regex && re.exactMatch(spec)) || (!regex && spec == config))
return true;
if (regex) {
QRegExp re(config, Qt::CaseSensitive, QRegExp::Wildcard);
if (re.exactMatch(Option::qmakespec))
return true;
// CONFIG variable
foreach (const QString &configValue, m_valuemap.value(QLatin1String("CONFIG"))) {
if (re.exactMatch(configValue))
return true;
}
} else {
// mkspecs
if (Option::qmakespec == config)
return true;
// CONFIG variable
foreach (const QString &configValue, m_valuemap.value(QLatin1String("CONFIG"))) {
if (configValue == config)
return true;
}
}
return false;
}
......
include(test.pri)
SOURCES += pro.cpp
CONFIG += testscope
testscope:SCOPED_VARIABLE = 1
......@@ -45,23 +45,32 @@ class tst_ProFileReader : public QObject
private slots:
void readProFile();
void includeFiles();
void conditionalScopes();
};
void tst_ProFileReader::readProFile()
{
ProFileCache cache;
ProFileReader reader(&cache);
ProFileReader reader;
QCOMPARE(reader.readProFile("nonexistant"), false);
QCOMPARE(reader.readProFile("data/includefiles/test.pro"), true);
}
void tst_ProFileReader::includeFiles()
{
ProFileCache cache;
ProFileReader reader(&cache);
ProFileReader reader;
QCOMPARE(reader.readProFile("data/includefiles/test.pro"), true);
QCOMPARE(reader.includeFiles().size(), 2);
}
void tst_ProFileReader::conditionalScopes()
{
ProFileReader reader;
QCOMPARE(reader.readProFile("data/includefiles/test.pro"), true);
QStringList scopedVariable = reader.values("SCOPED_VARIABLE");
QCOMPARE(scopedVariable.count(), 1);
QCOMPARE(scopedVariable.first(), QLatin1String("1"));
}
QTEST_MAIN(tst_ProFileReader)
#include "main.moc"
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment