diff options
author | Alexey Edelev <alexey.edelev@qt.io> | 2021-03-15 14:25:34 +0100 |
---|---|---|
committer | Alexey Edelev <alexey.edelev@qt.io> | 2021-03-17 11:57:11 +0100 |
commit | 6fb569af9512f63d503720ed7f62e9c70b16f969 (patch) | |
tree | 7a49c1fa32c064aeaefaa9ebec2c695c2fa275ad /qmake | |
parent | a423c0d21174fc88a02277d9cd909b0d6e11018b (diff) |
Unify QLibraryInfo settings
Exporting QLibraryInfo internals allows to reuse settings in
qmake/qtpath without having to keep its own instance.
Also there is no need to check setting groups in QLibraryInfo
except the 'Paths' group, since this logic belongs to qmake/qtpaths
only.
Change-Id: If762defba025ad7f7489f8a86ef5768a8628bd2f
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'qmake')
-rw-r--r-- | qmake/main.cpp | 3 | ||||
-rw-r--r-- | qmake/option.cpp | 7 | ||||
-rw-r--r-- | qmake/qmakelibraryinfo.cpp | 87 | ||||
-rw-r--r-- | qmake/qmakelibraryinfo.h | 9 |
4 files changed, 34 insertions, 72 deletions
diff --git a/qmake/main.cpp b/qmake/main.cpp index b00d110827..d435ecaed8 100644 --- a/qmake/main.cpp +++ b/qmake/main.cpp @@ -32,6 +32,7 @@ #include "option.h" #include "cachekeys.h" #include "metamakefile.h" +#include <qcoreapplication.h> #include <qnamespace.h> #include <qdebug.h> #include <qregularexpression.h> @@ -598,5 +599,7 @@ QT_END_NAMESPACE int main(int argc, char **argv) { + // Set name of the qmake application in QCoreApplication instance + QT_PREPEND_NAMESPACE(QCoreApplication) app(argc, argv); return QT_PREPEND_NAMESPACE(runQMake)(argc, argv); } diff --git a/qmake/option.cpp b/qmake/option.cpp index 1f9d60d7a8..9917447f91 100644 --- a/qmake/option.cpp +++ b/qmake/option.cpp @@ -33,10 +33,12 @@ #include <qregularexpression.h> #include <qhash.h> #include <qdebug.h> -#include <qmakelibraryinfo.h> #include <stdlib.h> #include <stdarg.h> +#include <qmakelibraryinfo.h> +#include <private/qlibraryinfo_p.h> + QT_BEGIN_NAMESPACE using namespace QMakeInternal; @@ -203,7 +205,7 @@ Option::parseCommandLine(QStringList &args, QMakeCmdLineParserState &state) default: QMakeGlobals::ArgumentReturn cmdRet = globals->addCommandLineArguments(state, args, &x); if (cmdRet == QMakeGlobals::ArgumentsOk) { - QMakeLibraryInfo::qtconfManualPath = globals->qtconf; + QLibraryInfoPrivate::qtconfManualPath = globals->qtconf; break; } if (cmdRet == QMakeGlobals::ArgumentMalformed) { @@ -340,7 +342,6 @@ Option::init(int argc, char **argv) #endif ; } - QMakeLibraryInfo::binaryAbsLocation = globals->qmake_abslocation; } else { Option::qmake_mode = Option::QMAKE_GENERATE_MAKEFILE; } diff --git a/qmake/qmakelibraryinfo.cpp b/qmake/qmakelibraryinfo.cpp index 4398e911f1..0d083e17d5 100644 --- a/qmake/qmakelibraryinfo.cpp +++ b/qmake/qmakelibraryinfo.cpp @@ -46,62 +46,27 @@ #include <qsettings.h> #include <qscopedpointer.h> #include <qstringlist.h> +#include <private/qlibraryinfo_p.h> #include <utility> QT_BEGIN_NAMESPACE -QString QMakeLibraryInfo::binaryAbsLocation; -QString QMakeLibraryInfo::qtconfManualPath; - struct QMakeLibrarySettings { QMakeLibrarySettings() { load(); } - void load(); - QScopedPointer<QSettings> settings; bool haveDevicePaths; bool haveEffectiveSourcePaths; bool haveEffectivePaths; bool havePaths; - bool reloadOnQAppAvailable; }; Q_GLOBAL_STATIC(QMakeLibrarySettings, qmake_library_settings) -QSettings *QMakeLibraryInfo::findConfiguration() -{ - QString qtconfig = libraryInfoFile(); - if (!qtconfig.isEmpty()) - return new QSettings(qtconfig, QSettings::IniFormat); - return nullptr; // no luck -} - -QSettings *QMakeLibraryInfo::configuration() -{ - QMakeLibrarySettings *ls = qmake_library_settings(); - return ls ? ls->settings.data() : nullptr; -} - -void QMakeLibraryInfo::reload() -{ - if (qmake_library_settings.exists()) - qmake_library_settings->load(); -} - -bool QMakeLibraryInfo::haveGroup(PathGroup group) -{ - QMakeLibrarySettings *ls = qmake_library_settings(); - return ls - && (group == EffectiveSourcePaths ? ls->haveEffectiveSourcePaths - : group == EffectivePaths ? ls->haveEffectivePaths - : group == DevicePaths ? ls->haveDevicePaths - : ls->havePaths); -} - void QMakeLibrarySettings::load() { - settings.reset(QMakeLibraryInfo::findConfiguration()); + QSettings *settings = QLibraryInfoPrivate::configuration(); if (settings) { QStringList children = settings->childGroups(); haveDevicePaths = children.contains(QLatin1String("DevicePaths")); @@ -120,6 +85,23 @@ void QMakeLibrarySettings::load() } } +void QMakeLibraryInfo::reload() +{ + QLibraryInfoPrivate::reload(); + if (qmake_library_settings.exists()) + qmake_library_settings->load(); +} + +bool QMakeLibraryInfo::haveGroup(PathGroup group) +{ + QMakeLibrarySettings *ls = qmake_library_settings(); + return ls + && (group == EffectiveSourcePaths ? ls->haveEffectiveSourcePaths + : group == EffectivePaths ? ls->haveEffectivePaths + : group == DevicePaths ? ls->haveDevicePaths + : ls->havePaths); +} + void QMakeLibraryInfo::sysrootify(QString &path) { // Acceptable values for SysrootifyPrefixPath are "true" and "false" @@ -165,9 +147,6 @@ static QLibraryInfo::LibraryPath hostToTargetPathEnum(int loc) qFatal("Unhandled host path %d in hostToTargetPathEnum.", loc); } -// from qlibraryinfo.cpp: -void qlibraryinfo_keyAndDefault(QLibraryInfo::LibraryPath loc, QString *key, QString *value); - struct LocationInfo { QString key; @@ -179,10 +158,10 @@ static LocationInfo defaultLocationInfo(int loc) LocationInfo result; if (loc < QMakeLibraryInfo::FirstHostPath) { - qlibraryinfo_keyAndDefault(static_cast<QLibraryInfo::LibraryPath>(loc), + QLibraryInfoPrivate::keyAndDefault(static_cast<QLibraryInfo::LibraryPath>(loc), &result.key, &result.defaultValue); } else if (loc <= QMakeLibraryInfo::LastHostPath) { - qlibraryinfo_keyAndDefault(hostToTargetPathEnum(loc), &result.key, &result.defaultValue); + QLibraryInfoPrivate::keyAndDefault(hostToTargetPathEnum(loc), &result.key, &result.defaultValue); result.key.prepend(QStringLiteral("Host")); } else if (loc == QMakeLibraryInfo::SysrootPath) { result.key = QStringLiteral("Sysroot"); @@ -236,7 +215,8 @@ QString QMakeLibraryInfo::rawLocation(int loc, QMakeLibraryInfo::PathGroup group LocationInfo locinfo = defaultLocationInfo(loc); if (!locinfo.key.isNull()) { - QSettings *config = QMakeLibraryInfo::configuration(); + QSettings *config = QLibraryInfoPrivate::configuration(); + Q_ASSERT(config != nullptr); config->beginGroup(QLatin1String(group == DevicePaths ? "DevicePaths" : group == EffectiveSourcePaths ? "EffectiveSourcePaths" @@ -298,7 +278,10 @@ QString QMakeLibraryInfo::rawLocation(int loc, QMakeLibraryInfo::PathGroup group // We make the prefix/sysroot path absolute to the executable's directory. // loc == PrefixPath while a sysroot is set would make no sense here. // loc == SysrootPath only makes sense if qmake lives inside the sysroot itself. - baseDir = QFileInfo(libraryInfoFile()).absolutePath(); + QSettings *config = QLibraryInfoPrivate::configuration(); + if (config != nullptr) { + baseDir = QFileInfo(config->fileName()).absolutePath(); + } } else if (loc >= FirstHostPath && loc <= LastHostPath) { // We make any other host path absolute to the host prefix directory. baseDir = rawLocation(HostPrefixPath, group); @@ -313,20 +296,4 @@ QString QMakeLibraryInfo::rawLocation(int loc, QMakeLibraryInfo::PathGroup group return ret; } -QString QMakeLibraryInfo::libraryInfoFile() -{ - if (!qtconfManualPath.isEmpty()) - return qtconfManualPath; - if (!binaryAbsLocation.isEmpty()) { - QDir dir(QFileInfo(binaryAbsLocation).absolutePath()); - QString qtconfig = dir.filePath("qt" QT_STRINGIFY(QT_VERSION_MAJOR) ".conf"); - if (QFile::exists(qtconfig)) - return qtconfig; - qtconfig = dir.filePath("qt.conf"); - if (QFile::exists(qtconfig)) - return qtconfig; - } - return QString(); -} - QT_END_NAMESPACE diff --git a/qmake/qmakelibraryinfo.h b/qmake/qmakelibraryinfo.h index 896181493c..71cc3fc78a 100644 --- a/qmake/qmakelibraryinfo.h +++ b/qmake/qmakelibraryinfo.h @@ -50,10 +50,7 @@ class QSettings; struct QMakeLibraryInfo { - static QSettings *findConfiguration(); - static QSettings *configuration(); static QString path(int loc); - static QStringList platformPluginArguments(const QString &platformName); /* This enum has to start after the last value in QLibraryInfo::LibraryPath(NOT SettingsPath!). * See qconfig.cpp.in and QLibraryInfo for details. @@ -78,12 +75,6 @@ struct QMakeLibraryInfo static void reload(); static bool haveGroup(PathGroup group); static void sysrootify(QString &path); - - static QString binaryAbsLocation; - static QString qtconfManualPath; - -private: - static QString libraryInfoFile(); }; QT_END_NAMESPACE |