diff --git a/qmake/qmakelibraryinfo.cpp b/qmake/qmakelibraryinfo.cpp index 365e72e0fc2..c8461c1d75b 100644 --- a/qmake/qmakelibraryinfo.cpp +++ b/qmake/qmakelibraryinfo.cpp @@ -143,12 +143,15 @@ QString QMakeLibraryInfo::path(int loc) QString ret = rawLocation(loc, QMakeLibraryInfo::FinalPaths); // Automatically prepend the sysroot to target paths - if (loc < QMakeLibraryInfo::FirstHostPath || loc > QMakeLibraryInfo::LastHostPath) + if (loc < QMakeLibraryInfo::FirstHostPath) sysrootify(ret); return ret; } +// from qlibraryinfo.cpp: +void qlibraryinfo_keyAndDefault(QLibraryInfo::LibraryPath loc, QString *key, QString *value); + struct LocationInfo { QString key; @@ -159,7 +162,10 @@ static LocationInfo defaultLocationInfo(int loc) { LocationInfo result; - if (loc == QMakeLibraryInfo::SysrootPath) { + if (loc < QMakeLibraryInfo::FirstHostPath) { + qlibraryinfo_keyAndDefault(static_cast(loc), + &result.key, &result.defaultValue); + } else if (loc == QMakeLibraryInfo::SysrootPath) { result.key = QStringLiteral("Sysroot"); } else if (loc == QMakeLibraryInfo::SysrootifyPrefixPath) { result.key = QStringLiteral("SysrootifyPrefix"); @@ -171,12 +177,6 @@ static LocationInfo defaultLocationInfo(int loc) result.key = QLatin1String(qtConfEntries[loc].key); result.defaultValue = QLatin1String(qtConfEntries[loc].value); } -#ifndef Q_OS_WIN // On Windows we use the registry - else if (loc == QLibraryInfo::SettingsPath) { - result.key = QLatin1String("Settings"); - result.defaultValue = QLatin1String("."); - } -#endif return result; } @@ -190,7 +190,9 @@ static QString storedPath(int loc) // will be built with a dummy path, thus the compile-time result of // strlen is meaningless. const char *volatile path = nullptr; - if (loc == QLibraryInfo::PrefixPath || loc == QMakeLibraryInfo::HostPrefixPath) { + if (loc < QMakeLibraryInfo::FirstHostPath) { + result = QLibraryInfo::path(static_cast(loc)); + } else if (loc == QMakeLibraryInfo::HostPrefixPath) { result = QLibraryInfo::path(QLibraryInfo::PrefixPath); } else if (loc == QMakeLibraryInfo::SysrootPath) { // empty result @@ -203,10 +205,6 @@ static QString storedPath(int loc) } else if (unsigned(loc) <= sizeof(qt_configure_str_offsets) / sizeof(qt_configure_str_offsets[0])) { path = qt_configure_strs + qt_configure_str_offsets[loc - 1]; -#ifndef Q_OS_WIN // On Windows we use the registry - } else if (loc == QLibraryInfo::SettingsPath) { - path = QT_CONFIGURE_SETTINGS_PATH; -#endif } if (path) diff --git a/qmake/qmakelibraryinfo.h b/qmake/qmakelibraryinfo.h index 8d9f1455e61..bf1bae81d8e 100644 --- a/qmake/qmakelibraryinfo.h +++ b/qmake/qmakelibraryinfo.h @@ -64,12 +64,12 @@ struct QMakeLibraryInfo HostLibraryExecutablesPath, HostLibrariesPath, HostDataPath, + HostPrefixPath, + LastHostPath = HostPrefixPath, TargetSpecPath, HostSpecPath, - HostPrefixPath, SysrootPath, - SysrootifyPrefixPath, - LastHostPath = SysrootifyPrefixPath + SysrootifyPrefixPath }; enum PathGroup { FinalPaths, EffectivePaths, EffectiveSourcePaths, DevicePaths }; static QString rawLocation(int loc, PathGroup group); diff --git a/src/corelib/global/qconfig.cpp.in b/src/corelib/global/qconfig.cpp.in index 161ae0b6cdd..e27f3c3e693 100644 --- a/src/corelib/global/qconfig.cpp.in +++ b/src/corelib/global/qconfig.cpp.in @@ -91,9 +91,9 @@ static const struct { #endif { "HostLibraries", "lib" }, { "HostData", "." }, + { "HostPrefix", "" }, { "TargetSpec", "" }, { "HostSpec", "" }, - { "HostPrefix", "" }, { "Sysroot", "" }, { "SysrootifyPrefix", "" }, #endif diff --git a/src/corelib/global/qlibraryinfo.cpp b/src/corelib/global/qlibraryinfo.cpp index f6c755b750d..0bd6674b43d 100644 --- a/src/corelib/global/qlibraryinfo.cpp +++ b/src/corelib/global/qlibraryinfo.cpp @@ -476,6 +476,25 @@ static QString getPrefix() #endif } +Q_CORE_EXPORT void qlibraryinfo_keyAndDefault(QLibraryInfo::LibraryPath loc, QString *key, + QString *value) +{ + if (unsigned(loc) < sizeof(qtConfEntries)/sizeof(qtConfEntries[0])) { + *key = QLatin1String(qtConfEntries[loc].key); + *value = QLatin1String(qtConfEntries[loc].value); + } +#ifndef Q_OS_WIN // On Windows we use the registry + else if (loc == QLibraryInfo::SettingsPath) { + *key = QLatin1String("Settings"); + *value = QLatin1String("."); + } +#endif + else { + key->clear(); + value->clear(); + } +} + /*! \fn QString QLibraryInfo::location(LibraryLocation loc) \obsolete Use path() instead. @@ -499,17 +518,7 @@ QString QLibraryInfo::path(LibraryPath p) QString key; QString defaultValue; - if (unsigned(loc) < sizeof(qtConfEntries)/sizeof(qtConfEntries[0])) { - key = QLatin1String(qtConfEntries[loc].key); - defaultValue = QLatin1String(qtConfEntries[loc].value); - } -#ifndef Q_OS_WIN // On Windows we use the registry - else if (loc == SettingsPath) { - key = QLatin1String("Settings"); - defaultValue = QLatin1String("."); - } -#endif - + qlibraryinfo_keyAndDefault(loc, &key, &defaultValue); if (!key.isNull()) { QSettings *config = QLibraryInfoPrivate::configuration(); config->beginGroup(QLatin1String("Paths"));