summaryrefslogtreecommitdiffstats
path: root/qmake
diff options
context:
space:
mode:
authorJoerg Bornemann <joerg.bornemann@qt.io>2021-03-05 21:57:51 +0100
committerJoerg Bornemann <joerg.bornemann@qt.io>2021-03-11 10:00:11 +0100
commit9f5a7cb5fa5630db484891c50fc3409871bc3d8a (patch)
treee7f3428eae4c9ff96597d3a6a7a85787ac210f0e /qmake
parenta08b1f63595f61e7fa12b04d516ec20396906c9e (diff)
qmake: Do not read from qmakeconfig.cpp
Change-Id: I6a46c2e817f8dc3f580774aba2db8bfb01f5a403 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'qmake')
-rw-r--r--qmake/qmakelibraryinfo.cpp42
-rw-r--r--qmake/qmakelibraryinfo.h2
2 files changed, 25 insertions, 19 deletions
diff --git a/qmake/qmakelibraryinfo.cpp b/qmake/qmakelibraryinfo.cpp
index c8461c1d75..4edff1142a 100644
--- a/qmake/qmakelibraryinfo.cpp
+++ b/qmake/qmakelibraryinfo.cpp
@@ -49,6 +49,8 @@
#include <qmakeconfig.cpp>
+#include <utility>
+
QT_BEGIN_NAMESPACE
QString QMakeLibraryInfo::binaryAbsLocation;
@@ -149,6 +151,22 @@ QString QMakeLibraryInfo::path(int loc)
return ret;
}
+static QLibraryInfo::LibraryPath hostToTargetPathEnum(int loc)
+{
+ static std::pair<int, QLibraryInfo::LibraryPath> mapping[] = {
+ { QMakeLibraryInfo::HostBinariesPath, QLibraryInfo::BinariesPath },
+ { QMakeLibraryInfo::HostLibraryExecutablesPath, QLibraryInfo::LibraryExecutablesPath },
+ { QMakeLibraryInfo::HostLibrariesPath, QLibraryInfo::LibrariesPath },
+ { QMakeLibraryInfo::HostDataPath, QLibraryInfo::DataPath },
+ { QMakeLibraryInfo::HostPrefixPath, QLibraryInfo::PrefixPath }
+ };
+ for (size_t i = 0; i < sizeof(mapping) / sizeof(mapping[0]); ++i) {
+ if (mapping[i].first == loc)
+ return mapping[i].second;
+ }
+ qFatal("Unhandled host path %d in hostToTargetPathEnum.", loc);
+}
+
// from qlibraryinfo.cpp:
void qlibraryinfo_keyAndDefault(QLibraryInfo::LibraryPath loc, QString *key, QString *value);
@@ -165,6 +183,9 @@ static LocationInfo defaultLocationInfo(int loc)
if (loc < QMakeLibraryInfo::FirstHostPath) {
qlibraryinfo_keyAndDefault(static_cast<QLibraryInfo::LibraryPath>(loc),
&result.key, &result.defaultValue);
+ } else if (loc <= QMakeLibraryInfo::LastHostPath) {
+ qlibraryinfo_keyAndDefault(hostToTargetPathEnum(loc), &result.key, &result.defaultValue);
+ result.key.prepend(QStringLiteral("Host"));
} else if (loc == QMakeLibraryInfo::SysrootPath) {
result.key = QStringLiteral("Sysroot");
} else if (loc == QMakeLibraryInfo::SysrootifyPrefixPath) {
@@ -173,9 +194,6 @@ static LocationInfo defaultLocationInfo(int loc)
result.key = QStringLiteral("TargetSpec");
} else if (loc == QMakeLibraryInfo::HostSpecPath) {
result.key = QStringLiteral("HostSpec");
- } else if (unsigned(loc) < sizeof(qtConfEntries) / sizeof(qtConfEntries[0])) {
- result.key = QLatin1String(qtConfEntries[loc].key);
- result.defaultValue = QLatin1String(qtConfEntries[loc].value);
}
return result;
}
@@ -183,17 +201,10 @@ static LocationInfo defaultLocationInfo(int loc)
static QString storedPath(int loc)
{
QString result;
-
- // "volatile" here is a hack to prevent compilers from doing a
- // compile-time strlen() on "path". The issue is that Qt installers
- // will binary-patch the Qt installation paths -- in such scenarios, Qt
- // will be built with a dummy path, thus the compile-time result of
- // strlen is meaningless.
- const char *volatile path = nullptr;
if (loc < QMakeLibraryInfo::FirstHostPath) {
result = QLibraryInfo::path(static_cast<QLibraryInfo::LibraryPath>(loc));
- } else if (loc == QMakeLibraryInfo::HostPrefixPath) {
- result = QLibraryInfo::path(QLibraryInfo::PrefixPath);
+ } else if (loc <= QMakeLibraryInfo::LastHostPath) {
+ result = QLibraryInfo::path(hostToTargetPathEnum(loc));
} else if (loc == QMakeLibraryInfo::SysrootPath) {
// empty result
} else if (loc == QMakeLibraryInfo::SysrootifyPrefixPath) {
@@ -202,14 +213,7 @@ static QString storedPath(int loc)
result = QT_TARGET_MKSPEC;
} else if (loc == QMakeLibraryInfo::HostSpecPath) {
result = QT_HOST_MKSPEC;
- } 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];
}
-
- if (path)
- result = QString::fromLocal8Bit(path);
-
return result;
}
diff --git a/qmake/qmakelibraryinfo.h b/qmake/qmakelibraryinfo.h
index bf1bae81d8..896181493c 100644
--- a/qmake/qmakelibraryinfo.h
+++ b/qmake/qmakelibraryinfo.h
@@ -57,6 +57,8 @@ struct QMakeLibraryInfo
/* This enum has to start after the last value in QLibraryInfo::LibraryPath(NOT SettingsPath!).
* See qconfig.cpp.in and QLibraryInfo for details.
+ * When adding enum values between FirstHostPath and LastHostPath, make sure to adjust
+ * the hostToTargetPathEnum(int) function.
*/
enum LibraryPathQMakeExtras {
HostBinariesPath = QLibraryInfo::TestsPath + 1,