summaryrefslogtreecommitdiffstats
path: root/src/corelib/global/qlibraryinfo.cpp
diff options
context:
space:
mode:
authorAlexey Edelev <alexey.edelev@qt.io>2021-01-28 16:06:26 +0100
committerAlexey Edelev <alexey.edelev@qt.io>2021-02-25 16:08:43 +0100
commit43c28aa9046967abeb4ad042c8be1aa23a19c282 (patch)
treeb8f4a53cd9aaaa819c853ee51e66ea100c1ae3d5 /src/corelib/global/qlibraryinfo.cpp
parent5a3bbb55851b84aa6a46c23e5a6fb33b4860edc6 (diff)
Use Core library for qmake instead of the Bootstrap library
Move the qmake-specific logic of the QLibraryInfo class to qmake internals. 'qconfig.cpp.in' now stores information about the library info entries to keep them consistent between qmake and the Core library. qmake requires specific features enabled in the Core library, so building qmake will be skipped if the features are not enabled. All flags directly related to the qmake have been removed from Core lib. Remove all bootstrap related sections from qmake CMakeLists.txt Task-number: QTBUG-89369 Change-Id: I26de157d3bfd4a5526699296e9d46e1c180b89ae Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Kai Koehne <kai.koehne@qt.io>
Diffstat (limited to 'src/corelib/global/qlibraryinfo.cpp')
-rw-r--r--src/corelib/global/qlibraryinfo.cpp271
1 files changed, 12 insertions, 259 deletions
diff --git a/src/corelib/global/qlibraryinfo.cpp b/src/corelib/global/qlibraryinfo.cpp
index d3f0f95ad8..b48b1b5d95 100644
--- a/src/corelib/global/qlibraryinfo.cpp
+++ b/src/corelib/global/qlibraryinfo.cpp
@@ -47,13 +47,7 @@
#include "qlibraryinfo.h"
#include "qscopedpointer.h"
-#ifdef QT_BUILD_QMAKE
-QT_BEGIN_NAMESPACE
-extern QString qmake_libraryInfoFile();
-QT_END_NAMESPACE
-#else
-# include "qcoreapplication.h"
-#endif
+#include "qcoreapplication.h"
#include "private/qglobal_p.h"
#include "qconfig.cpp"
@@ -64,12 +58,12 @@ QT_END_NAMESPACE
#include "archdetect.cpp"
-#if !defined(QT_BUILD_QMAKE) && QT_CONFIG(relocatable) && QT_CONFIG(dlopen) && !QT_CONFIG(framework)
-# include <dlfcn.h>
+#if QT_CONFIG(relocatable) && QT_CONFIG(dlopen) && !QT_CONFIG(framework)
+# include <dlfcn.h>
#endif
-#if !defined(QT_BUILD_QMAKE) && QT_CONFIG(relocatable) && defined(Q_OS_WIN)
-# include <qt_windows.h>
+#if QT_CONFIG(relocatable) && defined(Q_OS_WIN)
+# include <qt_windows.h>
#endif
QT_BEGIN_NAMESPACE
@@ -84,14 +78,7 @@ struct QLibrarySettings
void load();
QScopedPointer<QSettings> settings;
-#ifdef QT_BUILD_QMAKE
- bool haveDevicePaths;
- bool haveEffectiveSourcePaths;
- bool haveEffectivePaths;
- bool havePaths;
-#else
bool reloadOnQAppAvailable;
-#endif
};
Q_GLOBAL_STATIC(QLibrarySettings, qt_library_settings)
@@ -99,32 +86,12 @@ class QLibraryInfoPrivate
{
public:
static QSettings *findConfiguration();
-#ifdef QT_BUILD_QMAKE
- static void reload()
- {
- if (qt_library_settings.exists())
- qt_library_settings->load();
- }
- static bool haveGroup(QLibraryInfo::PathGroup group)
- {
- QLibrarySettings *ls = qt_library_settings();
- return ls ? (group == QLibraryInfo::EffectiveSourcePaths
- ? ls->haveEffectiveSourcePaths
- : group == QLibraryInfo::EffectivePaths
- ? ls->haveEffectivePaths
- : group == QLibraryInfo::DevicePaths
- ? ls->haveDevicePaths
- : ls->havePaths) : false;
- }
-#endif
static QSettings *configuration()
{
QLibrarySettings *ls = qt_library_settings();
if (ls) {
-#ifndef QT_BUILD_QMAKE
if (ls->reloadOnQAppAvailable && QCoreApplication::instance() != nullptr)
ls->load();
-#endif
return ls->settings.data();
} else {
return nullptr;
@@ -132,8 +99,6 @@ public:
}
};
-static const char platformsSection[] = "Platforms";
-
QLibrarySettings::QLibrarySettings()
{
load();
@@ -143,48 +108,29 @@ void QLibrarySettings::load()
{
// If we get any settings here, those won't change when the application shows up.
settings.reset(QLibraryInfoPrivate::findConfiguration());
-#ifndef QT_BUILD_QMAKE
reloadOnQAppAvailable = (settings.data() == nullptr && QCoreApplication::instance() == nullptr);
bool haveDevicePaths;
bool haveEffectivePaths;
bool havePaths;
-#endif
if (settings) {
// This code needs to be in the regular library, as otherwise a qt.conf that
// works for qmake would break things for dynamically built Qt tools.
QStringList children = settings->childGroups();
haveDevicePaths = children.contains(QLatin1String("DevicePaths"));
-#ifdef QT_BUILD_QMAKE
- haveEffectiveSourcePaths = children.contains(QLatin1String("EffectiveSourcePaths"));
-#else
// EffectiveSourcePaths is for the Qt build only, so needs no backwards compat trickery.
bool haveEffectiveSourcePaths = false;
-#endif
haveEffectivePaths = haveEffectiveSourcePaths || children.contains(QLatin1String("EffectivePaths"));
// Backwards compat: an existing but empty file is claimed to contain the Paths section.
havePaths = (!haveDevicePaths && !haveEffectivePaths
&& !children.contains(QLatin1String(platformsSection)))
|| children.contains(QLatin1String("Paths"));
-#ifndef QT_BUILD_QMAKE
if (!havePaths)
settings.reset(nullptr);
-#else
- } else {
- haveDevicePaths = false;
- haveEffectiveSourcePaths = false;
- haveEffectivePaths = false;
- havePaths = false;
-#endif
}
}
QSettings *QLibraryInfoPrivate::findConfiguration()
{
-#ifdef QT_BUILD_QMAKE
- QString qtconfig = qmake_libraryInfoFile();
- if (!qtconfig.isEmpty())
- return new QSettings(qtconfig, QSettings::IniFormat);
-#else
QString qtconfig = QStringLiteral(":/qt/etc/qt.conf");
if (QFile::exists(qtconfig))
return new QSettings(qtconfig, QSettings::IniFormat);
@@ -212,7 +158,6 @@ QSettings *QLibraryInfoPrivate::findConfiguration()
if (QFile::exists(qtconfig))
return new QSettings(qtconfig, QSettings::IniFormat);
}
-#endif
return nullptr; //no luck
}
@@ -236,8 +181,6 @@ QSettings *QLibraryInfoPrivate::findConfiguration()
\sa QSysInfo, {Using qt.conf}
*/
-#ifndef QT_BUILD_QMAKE
-
/*!
\internal
@@ -354,81 +297,6 @@ QVersionNumber QLibraryInfo::version() noexcept
}
#endif // QT_BOOTSTRAPPED
-#endif // QT_BUILD_QMAKE
-
-/*
- * To add a new entry in QLibrary::LibraryPath, add it to the enum above the bootstrapped values and:
- * - add its relative path in the qtConfEntries[] array below
- * (the key is what appears in a qt.conf file)
- * - add a property name in qmake/property.cpp propList[] array
- * (it's used with qmake -query)
- * - add to qt_config.prf, qt_module.prf, qt_module_fwdpri.prf
- */
-
-#ifdef QT_BUILD_QMAKE
-constexpr size_t qtConfEntriesKeySize = 23;
-#else
-constexpr size_t qtConfEntriesKeySize = 19;
-#endif
-
-static const struct {
- char key[qtConfEntriesKeySize], value[13];
-} qtConfEntries[] = {
- { "Prefix", "." },
- { "Documentation", "doc" }, // should be ${Data}/doc
- { "Headers", "include" },
- { "Libraries", "lib" },
-#ifdef Q_OS_WIN
- { "LibraryExecutables", "bin" },
-#else
- { "LibraryExecutables", "libexec" }, // should be ${ArchData}/libexec
-#endif
- { "Binaries", "bin" },
- { "Plugins", "plugins" }, // should be ${ArchData}/plugins
- { "Qml2Imports", "qml" }, // should be ${ArchData}/qml
- { "ArchData", "." },
- { "Data", "." },
- { "Translations", "translations" }, // should be ${Data}/translations
- { "Examples", "examples" },
- { "Tests", "tests" },
-#ifdef QT_BUILD_QMAKE
- { "Sysroot", "" },
- { "SysrootifyPrefix", "" },
- { "HostBinaries", "bin" },
- { "HostLibraryExecutables", "libexec" },
- { "HostLibraries", "lib" },
- { "HostData", "." },
- { "TargetSpec", "" },
- { "HostSpec", "" },
- { "HostPrefix", "" },
-#endif
-};
-
-#ifdef QT_BUILD_QMAKE
-void QLibraryInfo::reload()
-{
- QLibraryInfoPrivate::reload();
-}
-
-void QLibraryInfo::sysrootify(QString *path)
-{
- if (!QVariant::fromValue(rawLocation(SysrootifyPrefixPath, FinalPaths)).toBool())
- return;
-
- const QString sysroot = rawLocation(SysrootPath, FinalPaths);
- if (sysroot.isEmpty())
- return;
-
- if (path->length() > 2 && path->at(1) == QLatin1Char(':')
- && (path->at(2) == QLatin1Char('/') || path->at(2) == QLatin1Char('\\'))) {
- path->replace(0, 2, sysroot); // Strip out the drive on Windows targets
- } else {
- path->prepend(sysroot);
- }
-}
-#endif // QT_BUILD_QMAKE
-
-#ifndef QT_BUILD_QMAKE
static QString prefixFromAppDirHelper()
{
QString appDir;
@@ -458,9 +326,8 @@ static QString prefixFromAppDirHelper()
return appDir;
}
-#endif
-#if !defined(QT_BUILD_QMAKE) && QT_CONFIG(relocatable)
+#if QT_CONFIG(relocatable)
#if !defined(QT_STATIC) && !(defined(Q_OS_DARWIN) && QT_CONFIG(framework)) \
&& (QT_CONFIG(dlopen) || defined(Q_OS_WIN))
static QString prefixFromQtCoreLibraryHelper(const QString &qtCoreLibraryPath)
@@ -600,42 +467,9 @@ static QString getRelocatablePrefix()
}
#endif
-#if defined(QT_BUILD_QMAKE)
-QString qmake_abslocation();
-
-static QString getPrefixFromHostBinDir(const char *hostBinDirToPrefixPath)
+static QString getPrefix()
{
- const QString canonicalQMakePath = QFileInfo(qmake_abslocation()).canonicalPath();
- return QDir::cleanPath(canonicalQMakePath + QLatin1Char('/')
- + QLatin1String(hostBinDirToPrefixPath));
-}
-
-static QString getExtPrefixFromHostBinDir()
-{
- return getPrefixFromHostBinDir(QT_CONFIGURE_HOSTBINDIR_TO_EXTPREFIX_PATH);
-}
-
-static QString getHostPrefixFromHostBinDir()
-{
- return getPrefixFromHostBinDir(QT_CONFIGURE_HOSTBINDIR_TO_HOSTPREFIX_PATH);
-}
-#endif
-
-static QString getPrefix(
-#ifdef QT_BUILD_QMAKE
- QLibraryInfo::PathGroup group
-#endif
- )
-{
-#if defined(QT_BUILD_QMAKE)
-# if QT_CONFIGURE_CROSSBUILD
- if (group == QLibraryInfo::DevicePaths)
- return QString::fromLocal8Bit(QT_CONFIGURE_PREFIX_PATH);
-# else
- Q_UNUSED(group);
-# endif
- return getExtPrefixFromHostBinDir();
-#elif QT_CONFIG(relocatable)
+#if QT_CONFIG(relocatable)
return getRelocatablePrefix();
#else
return QString::fromLocal8Bit(QT_CONFIGURE_PREFIX_PATH);
@@ -656,40 +490,10 @@ static QString getPrefix(
QString QLibraryInfo::path(LibraryPath p)
{
const LibraryPath loc = p;
-#ifdef QT_BUILD_QMAKE // ends inside rawLocation !
- QString ret = rawLocation(loc, FinalPaths);
-
- // Automatically prepend the sysroot to target paths
- if (loc < SysrootPath || loc > LastHostPath)
- sysrootify(&ret);
-
- return ret;
-}
-
-QString
-QLibraryInfo::rawLocation(LibraryPath loc, PathGroup group)
-{
-#endif // QT_BUILD_QMAKE, started inside path!
QString ret;
bool fromConf = false;
#if QT_CONFIG(settings)
-#ifdef QT_BUILD_QMAKE
- // Logic for choosing the right data source: if EffectivePaths are requested
- // and qt.conf with that section is present, use it, otherwise fall back to
- // FinalPaths. For FinalPaths, use qt.conf if present and contains not only
- // [EffectivePaths], otherwise fall back to builtins.
- // EffectiveSourcePaths falls back to EffectivePaths.
- // DevicePaths falls back to FinalPaths.
- PathGroup orig_group = group;
- if (QLibraryInfoPrivate::haveGroup(group)
- || (group == EffectiveSourcePaths
- && (group = EffectivePaths, QLibraryInfoPrivate::haveGroup(group)))
- || ((group == EffectivePaths || group == DevicePaths)
- && (group = FinalPaths, QLibraryInfoPrivate::haveGroup(group)))
- || (group = orig_group, false))
-#else
if (QLibraryInfoPrivate::configuration())
-#endif
{
fromConf = true;
@@ -708,28 +512,9 @@ QLibraryInfo::rawLocation(LibraryPath loc, PathGroup group)
if (!key.isNull()) {
QSettings *config = QLibraryInfoPrivate::configuration();
- config->beginGroup(QLatin1String(
-#ifdef QT_BUILD_QMAKE
- group == DevicePaths ? "DevicePaths" :
- group == EffectiveSourcePaths ? "EffectiveSourcePaths" :
- group == EffectivePaths ? "EffectivePaths" :
-#endif
- "Paths"));
+ config->beginGroup(QLatin1String("Paths"));
ret = config->value(key, defaultValue).toString();
-
-#ifdef QT_BUILD_QMAKE
- if (ret.isEmpty()) {
- if (loc == HostPrefixPath)
- ret = config->value(QLatin1String(qtConfEntries[PrefixPath].key),
- QLatin1String(qtConfEntries[PrefixPath].value)).toString();
- else if (loc == TargetSpecPath || loc == HostSpecPath || loc == SysrootifyPrefixPath)
- fromConf = false;
- // The last case here is SysrootPath, which can be legitimately empty.
- // All other keys have non-empty fallbacks to start with.
- }
-#endif
-
int startIndex = 0;
forever {
startIndex = ret.indexOf(QLatin1Char('$'), startIndex);
@@ -765,59 +550,27 @@ QLibraryInfo::rawLocation(LibraryPath loc, PathGroup group)
// strlen is meaningless.
const char * volatile path = nullptr;
if (loc == PrefixPath) {
- ret = getPrefix(
-#ifdef QT_BUILD_QMAKE
- group
-#endif
- );
+ ret = getPrefix();
} 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 == SettingsPath) {
path = QT_CONFIGURE_SETTINGS_PATH;
#endif
-# ifdef QT_BUILD_QMAKE
- } else if (loc == HostPrefixPath) {
- static const QByteArray hostPrefixPath = getHostPrefixFromHostBinDir().toLatin1();
- path = hostPrefixPath.constData();
-# endif
}
if (path)
ret = QString::fromLocal8Bit(path);
}
-#ifdef QT_BUILD_QMAKE
- // These values aren't actually paths and thus need to be returned verbatim.
- if (loc == TargetSpecPath || loc == HostSpecPath || loc == SysrootifyPrefixPath)
- return ret;
-#endif
-
if (!ret.isEmpty() && QDir::isRelativePath(ret)) {
QString baseDir;
-#ifdef QT_BUILD_QMAKE
- if (loc == HostPrefixPath || loc == PrefixPath || loc == SysrootPath) {
- // 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(qmake_libraryInfoFile()).absolutePath();
- } else if (loc > SysrootPath && loc <= LastHostPath) {
- // We make any other host path absolute to the host prefix directory.
- baseDir = rawLocation(HostPrefixPath, group);
- } else {
- // we make any other path absolute to the prefix directory
- baseDir = rawLocation(PrefixPath, group);
- if (group == EffectivePaths)
- sysrootify(&baseDir);
- }
-#else
if (loc == PrefixPath) {
baseDir = prefixFromAppDirHelper();
} else {
// we make any other path absolute to the prefix directory
baseDir = path(PrefixPath);
}
-#endif // QT_BUILD_QMAKE
ret = QDir::cleanPath(baseDir + QLatin1Char('/') + ret);
}
return ret;
@@ -838,7 +591,7 @@ QLibraryInfo::rawLocation(LibraryPath loc, PathGroup group)
QStringList QLibraryInfo::platformPluginArguments(const QString &platformName)
{
-#if !defined(QT_BUILD_QMAKE) && QT_CONFIG(settings)
+#if QT_CONFIG(settings)
QScopedPointer<const QSettings> settings(QLibraryInfoPrivate::findConfiguration());
if (!settings.isNull()) {
const QString key = QLatin1String(platformsSection)
@@ -849,7 +602,7 @@ QStringList QLibraryInfo::platformPluginArguments(const QString &platformName)
}
#else
Q_UNUSED(platformName);
-#endif // !QT_BUILD_QMAKE && settings
+#endif // settings
return QStringList();
}