From 0158b185091db424516fb4de57b909a6e7e815b2 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Mon, 23 Jan 2017 15:58:55 +0100 Subject: qmake: updates to the parsing code of external properties sync-up with qt-creator; no effect on qmake. Change-Id: I7555de5c72a9250b31e20fc60e39680d19882fcb (cherry picked from qtcreator/2cb7c81e620d224d386860a637dc889acb15435e) (cherry picked from qtcreator/89868ee2b9093ecf40602ae302b991d6a60014b0) (cherry picked from qtcreator/03e699ce2985eedcd33d247aa47d04b14bc4bc04) (cherry picked from qtcreator/61419e7bf0f3bff6dcf63876b05b72c56e60c2a8) (cherry picked from qtcreator/19eaf87ef95a510351557119a955223a4aeea7b3) (cherry picked from qtcreator/3080bda0661989e88dfa62101b4c3f5d5e6754a1) (cherry picked from qtcreator/99714239b616e628ff4e0afe3db7eb7511ccf569) Reviewed-by: Joerg Bornemann --- qmake/library/qmakeglobals.cpp | 57 +++++++++++++++++++++++++++--------------- qmake/library/qmakeglobals.h | 1 + 2 files changed, 38 insertions(+), 20 deletions(-) (limited to 'qmake') diff --git a/qmake/library/qmakeglobals.cpp b/qmake/library/qmakeglobals.cpp index cab04fc239..452b44c045 100644 --- a/qmake/library/qmakeglobals.cpp +++ b/qmake/library/qmakeglobals.cpp @@ -327,6 +327,13 @@ bool QMakeGlobals::initProperties() QT_PCLOSE(proc); } #endif + parseProperties(data, properties); + return true; +} +#endif + +void QMakeGlobals::parseProperties(const QByteArray &data, QHash &properties) +{ const auto lines = data.split('\n'); for (QByteArray line : lines) { int off = line.indexOf(':'); @@ -337,40 +344,50 @@ 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('/')); - if (!plain) { - if (!name.endsWith(QLatin1String("/get"))) + enum { PropPut, PropRaw, PropGet } variant; + if (name.contains(QLatin1Char('/'))) { + if (name.endsWith(QLatin1String("/raw"))) + variant = PropRaw; + else if (name.endsWith(QLatin1String("/get"))) + variant = PropGet; + else // Nothing falls back on /src or /dev. continue; name.chop(4); + } else { + variant = PropPut; } if (name.startsWith(QLatin1String("QT_INSTALL_"))) { - if (plain) { - properties.insert(ProKey(name + QLatin1String("/raw")), value); - properties.insert(ProKey(name + QLatin1String("/get")), value); - } - properties.insert(ProKey(name + QLatin1String("/src")), value); - if (name == QLatin1String("QT_INSTALL_PREFIX") - || name == QLatin1String("QT_INSTALL_DATA") - || name == QLatin1String("QT_INSTALL_BINS")) { - name.replace(3, 7, QLatin1String("HOST")); - if (plain) { - properties.insert(ProKey(name), value); - properties.insert(ProKey(name + QLatin1String("/get")), value); + if (variant < PropRaw) { + if (name == QLatin1String("QT_INSTALL_PREFIX") + || name == QLatin1String("QT_INSTALL_DATA") + || name == QLatin1String("QT_INSTALL_LIBS") + || name == QLatin1String("QT_INSTALL_BINS")) { + // Qt4 fallback + QString hname = name; + hname.replace(3, 7, QLatin1String("HOST")); + properties.insert(ProKey(hname), value); + properties.insert(ProKey(hname + QLatin1String("/get")), value); + properties.insert(ProKey(hname + QLatin1String("/src")), value); } - properties.insert(ProKey(name + QLatin1String("/src")), value); + properties.insert(ProKey(name + QLatin1String("/raw")), value); } - } else if (name.startsWith(QLatin1String("QT_HOST_"))) { - if (plain) + if (variant <= PropRaw) + properties.insert(ProKey(name + QLatin1String("/dev")), value); + } else if (!name.startsWith(QLatin1String("QT_HOST_"))) { + continue; + } + if (variant != PropRaw) { + if (variant < PropGet) properties.insert(ProKey(name + QLatin1String("/get")), value); properties.insert(ProKey(name + QLatin1String("/src")), value); } } } - return true; } -#endif #endif // QT_BUILD_QMAKE QT_END_NAMESPACE diff --git a/qmake/library/qmakeglobals.h b/qmake/library/qmakeglobals.h index cf71a5afda..6c00b1f3af 100644 --- a/qmake/library/qmakeglobals.h +++ b/qmake/library/qmakeglobals.h @@ -131,6 +131,7 @@ public: void reloadProperties() { property->reload(); } ProString propertyValue(const ProKey &name) const { return property->value(name); } #else + static void parseProperties(const QByteArray &data, QHash &props); # ifdef PROEVALUATOR_INIT_PROPS bool initProperties(); # else -- cgit v1.2.3