forked from qt-creator/qt-creator
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.
This commit is contained in:
@@ -1297,10 +1297,28 @@ bool ProFileEvaluator::Private::isActiveConfig(const QString &config, bool regex
|
|||||||
if (Option::target_mode == Option::TARG_WIN_MODE && config == QLatin1String("win32"))
|
if (Option::target_mode == Option::TARG_WIN_MODE && config == QLatin1String("win32"))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
QRegExp re(config, Qt::CaseSensitive, QRegExp::Wildcard);
|
if (regex) {
|
||||||
QString spec = Option::qmakespec;
|
QRegExp re(config, Qt::CaseSensitive, QRegExp::Wildcard);
|
||||||
if ((regex && re.exactMatch(spec)) || (!regex && spec == config))
|
|
||||||
return true;
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
include(test.pri)
|
include(test.pri)
|
||||||
|
|
||||||
SOURCES += pro.cpp
|
SOURCES += pro.cpp
|
||||||
|
|
||||||
|
CONFIG += testscope
|
||||||
|
testscope:SCOPED_VARIABLE = 1
|
||||||
|
|||||||
@@ -45,23 +45,32 @@ class tst_ProFileReader : public QObject
|
|||||||
private slots:
|
private slots:
|
||||||
void readProFile();
|
void readProFile();
|
||||||
void includeFiles();
|
void includeFiles();
|
||||||
|
void conditionalScopes();
|
||||||
};
|
};
|
||||||
|
|
||||||
void tst_ProFileReader::readProFile()
|
void tst_ProFileReader::readProFile()
|
||||||
{
|
{
|
||||||
ProFileCache cache;
|
ProFileReader reader;
|
||||||
ProFileReader reader(&cache);
|
|
||||||
QCOMPARE(reader.readProFile("nonexistant"), false);
|
QCOMPARE(reader.readProFile("nonexistant"), false);
|
||||||
QCOMPARE(reader.readProFile("data/includefiles/test.pro"), true);
|
QCOMPARE(reader.readProFile("data/includefiles/test.pro"), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_ProFileReader::includeFiles()
|
void tst_ProFileReader::includeFiles()
|
||||||
{
|
{
|
||||||
ProFileCache cache;
|
ProFileReader reader;
|
||||||
ProFileReader reader(&cache);
|
|
||||||
QCOMPARE(reader.readProFile("data/includefiles/test.pro"), true);
|
QCOMPARE(reader.readProFile("data/includefiles/test.pro"), true);
|
||||||
QCOMPARE(reader.includeFiles().size(), 2);
|
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)
|
QTEST_MAIN(tst_ProFileReader)
|
||||||
#include "main.moc"
|
#include "main.moc"
|
||||||
|
|||||||
Reference in New Issue
Block a user