qmake: Do not read from qmakeconfig.cpp
Change-Id: I6a46c2e817f8dc3f580774aba2db8bfb01f5a403 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
parent
a08b1f6359
commit
9f5a7cb5fa
@ -49,6 +49,8 @@
|
|||||||
|
|
||||||
#include <qmakeconfig.cpp>
|
#include <qmakeconfig.cpp>
|
||||||
|
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
QString QMakeLibraryInfo::binaryAbsLocation;
|
QString QMakeLibraryInfo::binaryAbsLocation;
|
||||||
@ -149,6 +151,22 @@ QString QMakeLibraryInfo::path(int loc)
|
|||||||
return ret;
|
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:
|
// from qlibraryinfo.cpp:
|
||||||
void qlibraryinfo_keyAndDefault(QLibraryInfo::LibraryPath loc, QString *key, QString *value);
|
void qlibraryinfo_keyAndDefault(QLibraryInfo::LibraryPath loc, QString *key, QString *value);
|
||||||
|
|
||||||
@ -165,6 +183,9 @@ static LocationInfo defaultLocationInfo(int loc)
|
|||||||
if (loc < QMakeLibraryInfo::FirstHostPath) {
|
if (loc < QMakeLibraryInfo::FirstHostPath) {
|
||||||
qlibraryinfo_keyAndDefault(static_cast<QLibraryInfo::LibraryPath>(loc),
|
qlibraryinfo_keyAndDefault(static_cast<QLibraryInfo::LibraryPath>(loc),
|
||||||
&result.key, &result.defaultValue);
|
&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) {
|
} else if (loc == QMakeLibraryInfo::SysrootPath) {
|
||||||
result.key = QStringLiteral("Sysroot");
|
result.key = QStringLiteral("Sysroot");
|
||||||
} else if (loc == QMakeLibraryInfo::SysrootifyPrefixPath) {
|
} else if (loc == QMakeLibraryInfo::SysrootifyPrefixPath) {
|
||||||
@ -173,9 +194,6 @@ static LocationInfo defaultLocationInfo(int loc)
|
|||||||
result.key = QStringLiteral("TargetSpec");
|
result.key = QStringLiteral("TargetSpec");
|
||||||
} else if (loc == QMakeLibraryInfo::HostSpecPath) {
|
} else if (loc == QMakeLibraryInfo::HostSpecPath) {
|
||||||
result.key = QStringLiteral("HostSpec");
|
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;
|
return result;
|
||||||
}
|
}
|
||||||
@ -183,17 +201,10 @@ static LocationInfo defaultLocationInfo(int loc)
|
|||||||
static QString storedPath(int loc)
|
static QString storedPath(int loc)
|
||||||
{
|
{
|
||||||
QString result;
|
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) {
|
if (loc < QMakeLibraryInfo::FirstHostPath) {
|
||||||
result = QLibraryInfo::path(static_cast<QLibraryInfo::LibraryPath>(loc));
|
result = QLibraryInfo::path(static_cast<QLibraryInfo::LibraryPath>(loc));
|
||||||
} else if (loc == QMakeLibraryInfo::HostPrefixPath) {
|
} else if (loc <= QMakeLibraryInfo::LastHostPath) {
|
||||||
result = QLibraryInfo::path(QLibraryInfo::PrefixPath);
|
result = QLibraryInfo::path(hostToTargetPathEnum(loc));
|
||||||
} else if (loc == QMakeLibraryInfo::SysrootPath) {
|
} else if (loc == QMakeLibraryInfo::SysrootPath) {
|
||||||
// empty result
|
// empty result
|
||||||
} else if (loc == QMakeLibraryInfo::SysrootifyPrefixPath) {
|
} else if (loc == QMakeLibraryInfo::SysrootifyPrefixPath) {
|
||||||
@ -202,14 +213,7 @@ static QString storedPath(int loc)
|
|||||||
result = QT_TARGET_MKSPEC;
|
result = QT_TARGET_MKSPEC;
|
||||||
} else if (loc == QMakeLibraryInfo::HostSpecPath) {
|
} else if (loc == QMakeLibraryInfo::HostSpecPath) {
|
||||||
result = QT_HOST_MKSPEC;
|
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;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,6 +57,8 @@ struct QMakeLibraryInfo
|
|||||||
|
|
||||||
/* This enum has to start after the last value in QLibraryInfo::LibraryPath(NOT SettingsPath!).
|
/* This enum has to start after the last value in QLibraryInfo::LibraryPath(NOT SettingsPath!).
|
||||||
* See qconfig.cpp.in and QLibraryInfo for details.
|
* 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 {
|
enum LibraryPathQMakeExtras {
|
||||||
HostBinariesPath = QLibraryInfo::TestsPath + 1,
|
HostBinariesPath = QLibraryInfo::TestsPath + 1,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user