forked from qt-creator/qt-creator
de-duplicate qmake property parsing code
Change-Id: I7555de5c72a9250b31e20fc60e39680d19882fcb Reviewed-by: Tobias Hunger <tobias.hunger@qt.io> Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -1447,33 +1447,8 @@ bool BaseQtVersion::queryQMakeVariables(const FileName &binary, const Environmen
|
||||
if (output.isNull())
|
||||
return false;
|
||||
|
||||
QTextStream stream(&output);
|
||||
while (!stream.atEnd()) {
|
||||
const QString line = stream.readLine();
|
||||
const int index = line.indexOf(QLatin1Char(':'));
|
||||
if (index != -1) {
|
||||
QString name = line.left(index);
|
||||
ProString value(QDir::fromNativeSeparators(line.mid(index+1)));
|
||||
if (value.isNull())
|
||||
value = ProString(""); // Make sure it is not null, to discern from missing keys
|
||||
versionInfo->insert(ProKey(name), value);
|
||||
if (name.startsWith(QLatin1String("QT_")) && !name.contains(QLatin1Char('/'))) {
|
||||
if (name.startsWith(QLatin1String("QT_INSTALL_"))) {
|
||||
versionInfo->insert(ProKey(name + QLatin1String("/raw")), value);
|
||||
versionInfo->insert(ProKey(name + QLatin1String("/get")), value);
|
||||
if (name == QLatin1String("QT_INSTALL_PREFIX")
|
||||
|| name == QLatin1String("QT_INSTALL_DATA")
|
||||
|| name == QLatin1String("QT_INSTALL_BINS")) {
|
||||
name.replace(3, 7, QLatin1String("HOST"));
|
||||
versionInfo->insert(ProKey(name), value);
|
||||
versionInfo->insert(ProKey(name + QLatin1String("/get")), value);
|
||||
}
|
||||
} else if (name.startsWith(QLatin1String("QT_HOST_"))) {
|
||||
versionInfo->insert(ProKey(name + QLatin1String("/get")), value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
QMakeGlobals::parseProperties(output, *versionInfo);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -324,6 +324,13 @@ bool QMakeGlobals::initProperties()
|
||||
QT_PCLOSE(proc);
|
||||
}
|
||||
#endif
|
||||
parseProperties(data, properties);
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
void QMakeGlobals::parseProperties(const QByteArray &data, QHash<ProKey, ProString> &properties)
|
||||
{
|
||||
const auto lines = data.split('\n');
|
||||
for (QByteArray line : lines) {
|
||||
int off = line.indexOf(':');
|
||||
@@ -334,6 +341,8 @@ bool QMakeGlobals::initProperties()
|
||||
QString name = QString::fromLatin1(line.left(off));
|
||||
ProString value = ProString(QDir::fromNativeSeparators(
|
||||
QString::fromLocal8Bit(line.mid(off + 1))));
|
||||
if (value.isNull())
|
||||
value = ProString(""); // Make sure it is not null, to discern from missing keys
|
||||
properties.insert(ProKey(name), value);
|
||||
if (name.startsWith(QLatin1String("QT_"))) {
|
||||
bool plain = !name.contains(QLatin1Char('/'));
|
||||
@@ -365,9 +374,7 @@ bool QMakeGlobals::initProperties()
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
#endif // QT_BUILD_QMAKE
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
@@ -123,6 +123,7 @@ public:
|
||||
void setQMakeProperty(QMakeProperty *prop) { property = prop; }
|
||||
ProString propertyValue(const ProKey &name) const { return property->value(name); }
|
||||
#else
|
||||
static void parseProperties(const QByteArray &data, QHash<ProKey, ProString> &props);
|
||||
# ifdef PROEVALUATOR_INIT_PROPS
|
||||
bool initProperties();
|
||||
# else
|
||||
|
||||
Reference in New Issue
Block a user