From 0d7ed8f5f3b8a308c495c71c7427b41157d769b1 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Fri, 10 Feb 2017 17:39:47 +0100 Subject: streamline libdl detection and linking instead of having a library and a test, use a library with two sources, the first being empty (i.e., just libc). this allows us doing away with the "libdl" feature, and using just the "dlopen" one. subsequently, replace all LIBS+=$$QMAKE_LIBS_DYNLOAD with QMAKE_USE+=libdl. the definitions of QMAKE_LIBS_DYNLOAD remain in the qmakespecs for backwards compat only. n.b.: the only specs where it is not empty or "-ldl" (i.e., what we support now) are the hpux ones, where the library is called 'dld'. technically, the "library" feature should depend on '!unix || dlopen', but that's for a later patch. Change-Id: Ib8546affc4b7bc757f1a76729573ddd00e152176 Reviewed-by: Lars Knoll Reviewed-by: Ulf Hermann --- src/corelib/plugin/plugin.pri | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/corelib/plugin') diff --git a/src/corelib/plugin/plugin.pri b/src/corelib/plugin/plugin.pri index 473480eb55..bb3843cc36 100644 --- a/src/corelib/plugin/plugin.pri +++ b/src/corelib/plugin/plugin.pri @@ -35,4 +35,4 @@ integrity { SOURCES += plugin/qlibrary_unix.cpp } -!no-libdl: LIBS_PRIVATE += $$QMAKE_LIBS_DYNLOAD +qtConfig(dlopen): QMAKE_USE_PRIVATE += libdl -- cgit v1.2.3 From d6330a19b29ebff359a6746250c78437dbcaf77d Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Mon, 19 Dec 2016 10:34:32 +0100 Subject: Use QT_CONFIG(library) instead of QT_NO_LIBRARY For the windows file system engine, we add an extra macro to use library loading if configured to do so, but avoid it on WinRT, as none of the symbols would be found. We also QT_REQUIRE_CONFIG(library) in the library headers and exclude the sources from the build if library loading is disabled. This, in turn, makes it necessary to clean up some header inclusions. Change-Id: I2b152cb5b47a2658996b6f4702b038536a5704ec Reviewed-by: Oswald Buddenhagen --- src/corelib/plugin/plugin.pri | 53 +++++++++++++++++------------------ src/corelib/plugin/qelfparser_p.cpp | 2 -- src/corelib/plugin/qelfparser_p.h | 4 +-- src/corelib/plugin/qfactoryloader.cpp | 12 ++++---- src/corelib/plugin/qfactoryloader_p.h | 6 ++-- src/corelib/plugin/qlibrary.cpp | 4 --- src/corelib/plugin/qlibrary.h | 6 ++-- src/corelib/plugin/qlibrary_p.h | 7 ++--- src/corelib/plugin/qlibrary_unix.cpp | 4 --- src/corelib/plugin/qlibrary_win.cpp | 4 --- src/corelib/plugin/qmachparser.cpp | 2 +- src/corelib/plugin/qmachparser_p.h | 4 +-- src/corelib/plugin/qpluginloader.cpp | 4 +-- src/corelib/plugin/qpluginloader.h | 7 +++-- 14 files changed, 52 insertions(+), 67 deletions(-) (limited to 'src/corelib/plugin') diff --git a/src/corelib/plugin/plugin.pri b/src/corelib/plugin/plugin.pri index bb3843cc36..a0e0d76044 100644 --- a/src/corelib/plugin/plugin.pri +++ b/src/corelib/plugin/plugin.pri @@ -1,38 +1,37 @@ # Qt core library plugin module HEADERS += \ - plugin/qfactoryinterface.h \ - plugin/qpluginloader.h \ - plugin/qlibrary.h \ - plugin/qlibrary_p.h \ - plugin/qplugin.h \ - plugin/quuid.h \ - plugin/qfactoryloader_p.h \ - plugin/qsystemlibrary_p.h \ - plugin/qelfparser_p.h \ - plugin/qmachparser_p.h + plugin/qfactoryinterface.h \ + plugin/qpluginloader.h \ + plugin/qplugin.h \ + plugin/quuid.h \ + plugin/qfactoryloader_p.h SOURCES += \ - plugin/qfactoryinterface.cpp \ - plugin/qpluginloader.cpp \ - plugin/qfactoryloader.cpp \ - plugin/quuid.cpp \ - plugin/qlibrary.cpp \ - plugin/qelfparser_p.cpp \ - plugin/qmachparser.cpp + plugin/qfactoryinterface.cpp \ + plugin/qpluginloader.cpp \ + plugin/qfactoryloader.cpp \ + plugin/quuid.cpp win32 { - SOURCES += \ - plugin/qlibrary_win.cpp \ - plugin/qsystemlibrary.cpp + HEADERS += plugin/qsystemlibrary_p.h + SOURCES += plugin/qsystemlibrary.cpp } -unix { - SOURCES += plugin/qlibrary_unix.cpp -} +qtConfig(library) { + HEADERS += \ + plugin/qlibrary.h \ + plugin/qlibrary_p.h \ + plugin/qelfparser_p.h \ + plugin/qmachparser_p.h -integrity { - SOURCES += plugin/qlibrary_unix.cpp -} + SOURCES += \ + plugin/qlibrary.cpp \ + plugin/qelfparser_p.cpp \ + plugin/qmachparser.cpp + + unix: SOURCES += plugin/qlibrary_unix.cpp + else: SOURCES += plugin/qlibrary_win.cpp -qtConfig(dlopen): QMAKE_USE_PRIVATE += libdl + qtConfig(dlopen): QMAKE_USE_PRIVATE += libdl +} diff --git a/src/corelib/plugin/qelfparser_p.cpp b/src/corelib/plugin/qelfparser_p.cpp index ef1fc4ded3..85478e376e 100644 --- a/src/corelib/plugin/qelfparser_p.cpp +++ b/src/corelib/plugin/qelfparser_p.cpp @@ -39,7 +39,6 @@ #include "qelfparser_p.h" -#ifndef QT_NO_LIBRARY #if defined (Q_OF_ELF) && defined(Q_CC_GNU) #include "qlibrary_p.h" @@ -235,4 +234,3 @@ int QElfParser::parse(const char *dataStart, ulong fdlen, const QString &library QT_END_NAMESPACE #endif // defined(Q_OF_ELF) && defined(Q_CC_GNU) -#endif // QT_NO_LIBRARY diff --git a/src/corelib/plugin/qelfparser_p.h b/src/corelib/plugin/qelfparser_p.h index bcda19e8b5..3e73c5d149 100644 --- a/src/corelib/plugin/qelfparser_p.h +++ b/src/corelib/plugin/qelfparser_p.h @@ -54,7 +54,8 @@ #include #include -#ifndef QT_NO_LIBRARY +QT_REQUIRE_CONFIG(library); + #if defined (Q_OF_ELF) && defined(Q_CC_GNU) QT_BEGIN_NAMESPACE @@ -101,6 +102,5 @@ public: QT_END_NAMESPACE #endif // defined(Q_OF_ELF) && defined(Q_CC_GNU) -#endif // QT_NO_LIBRARY #endif // QELFPARSER_P_H diff --git a/src/corelib/plugin/qfactoryloader.cpp b/src/corelib/plugin/qfactoryloader.cpp index b8e18cc9a8..21f1007d5b 100644 --- a/src/corelib/plugin/qfactoryloader.cpp +++ b/src/corelib/plugin/qfactoryloader.cpp @@ -62,7 +62,7 @@ class QFactoryLoaderPrivate : public QObjectPrivate public: QFactoryLoaderPrivate(){} QByteArray iid; -#ifndef QT_NO_LIBRARY +#if QT_CONFIG(library) ~QFactoryLoaderPrivate(); mutable QMutex mutex; QList libraryList; @@ -73,7 +73,7 @@ public: #endif }; -#ifndef QT_NO_LIBRARY +#if QT_CONFIG(library) Q_GLOBAL_STATIC(QList, qt_factory_loaders) @@ -232,7 +232,7 @@ void QFactoryLoader::refreshAll() } } -#endif // QT_NO_LIBRARY +#endif // QT_CONFIG(library) QFactoryLoader::QFactoryLoader(const char *iid, const QString &suffix, @@ -242,7 +242,7 @@ QFactoryLoader::QFactoryLoader(const char *iid, moveToThread(QCoreApplicationPrivate::mainThread()); Q_D(QFactoryLoader); d->iid = iid; -#ifndef QT_NO_LIBRARY +#if QT_CONFIG(library) d->cs = cs; d->suffix = suffix; @@ -259,7 +259,7 @@ QList QFactoryLoader::metaData() const { Q_D(const QFactoryLoader); QList metaData; -#ifndef QT_NO_LIBRARY +#if QT_CONFIG(library) QMutexLocker locker(&d->mutex); for (int i = 0; i < d->libraryList.size(); ++i) metaData.append(d->libraryList.at(i)->metaData); @@ -281,7 +281,7 @@ QObject *QFactoryLoader::instance(int index) const if (index < 0) return 0; -#ifndef QT_NO_LIBRARY +#if QT_CONFIG(library) QMutexLocker lock(&d->mutex); if (index < d->libraryList.size()) { QLibraryPrivate *library = d->libraryList.at(index); diff --git a/src/corelib/plugin/qfactoryloader_p.h b/src/corelib/plugin/qfactoryloader_p.h index 70a934c976..7be18942ae 100644 --- a/src/corelib/plugin/qfactoryloader_p.h +++ b/src/corelib/plugin/qfactoryloader_p.h @@ -60,7 +60,9 @@ #include "QtCore/qjsondocument.h" #include "QtCore/qmap.h" #include "QtCore/qendian.h" +#if QT_CONFIG(library) #include "private/qlibrary_p.h" +#endif QT_BEGIN_NAMESPACE @@ -84,7 +86,7 @@ public: const QString &suffix = QString(), Qt::CaseSensitivity = Qt::CaseSensitive); -#ifndef QT_NO_LIBRARY +#if QT_CONFIG(library) ~QFactoryLoader(); void update(); @@ -93,7 +95,7 @@ public: #if defined(Q_OS_UNIX) && !defined (Q_OS_MAC) QLibraryPrivate *library(const QString &key) const; #endif // Q_OS_UNIX && !Q_OS_MAC -#endif // !QT_NO_LIBRARY +#endif // QT_CONFIG(library) QMultiMap keyMap() const; int indexOf(const QString &needle) const; diff --git a/src/corelib/plugin/qlibrary.cpp b/src/corelib/plugin/qlibrary.cpp index a4a654cd88..6421e7c5d8 100644 --- a/src/corelib/plugin/qlibrary.cpp +++ b/src/corelib/plugin/qlibrary.cpp @@ -40,8 +40,6 @@ #include "qplatformdefs.h" #include "qlibrary.h" -#ifndef QT_NO_LIBRARY - #include "qfactoryloader_p.h" #include "qlibrary_p.h" #include @@ -1131,5 +1129,3 @@ bool qt_debug_component() } QT_END_NAMESPACE - -#endif // QT_NO_LIBRARY diff --git a/src/corelib/plugin/qlibrary.h b/src/corelib/plugin/qlibrary.h index 2b91fa4007..89be52aac3 100644 --- a/src/corelib/plugin/qlibrary.h +++ b/src/corelib/plugin/qlibrary.h @@ -42,9 +42,9 @@ #include -QT_BEGIN_NAMESPACE +QT_REQUIRE_CONFIG(library); -#ifndef QT_NO_LIBRARY +QT_BEGIN_NAMESPACE class QLibraryPrivate; @@ -99,8 +99,6 @@ private: Q_DECLARE_OPERATORS_FOR_FLAGS(QLibrary::LoadHints) -#endif //QT_NO_LIBRARY - QT_END_NAMESPACE #endif //QLIBRARY_H diff --git a/src/corelib/plugin/qlibrary_p.h b/src/corelib/plugin/qlibrary_p.h index 7147ff6ca2..3f650501c8 100644 --- a/src/corelib/plugin/qlibrary_p.h +++ b/src/corelib/plugin/qlibrary_p.h @@ -62,10 +62,9 @@ # include "QtCore/qt_windows.h" #endif -QT_BEGIN_NAMESPACE - -#ifndef QT_NO_LIBRARY +QT_REQUIRE_CONFIG(library); +QT_BEGIN_NAMESPACE bool qt_debug_component(); @@ -130,8 +129,6 @@ private: friend class QLibraryStore; }; -#endif // QT_NO_LIBRARY - QT_END_NAMESPACE #endif // QLIBRARY_P_H diff --git a/src/corelib/plugin/qlibrary_unix.cpp b/src/corelib/plugin/qlibrary_unix.cpp index 8b16021303..6c1253ea08 100644 --- a/src/corelib/plugin/qlibrary_unix.cpp +++ b/src/corelib/plugin/qlibrary_unix.cpp @@ -44,8 +44,6 @@ #include #include -#ifndef QT_NO_LIBRARY - #ifdef Q_OS_MAC # include #endif @@ -308,5 +306,3 @@ QFunctionPointer QLibraryPrivate::resolve_sys(const char* symbol) } QT_END_NAMESPACE - -#endif // QT_NO_LIBRARY diff --git a/src/corelib/plugin/qlibrary_win.cpp b/src/corelib/plugin/qlibrary_win.cpp index 48aa0cdbb6..a4d3f67c27 100644 --- a/src/corelib/plugin/qlibrary_win.cpp +++ b/src/corelib/plugin/qlibrary_win.cpp @@ -44,8 +44,6 @@ #include "qfileinfo.h" #include -#ifndef QT_NO_LIBRARY - #include QT_BEGIN_NAMESPACE @@ -174,5 +172,3 @@ QFunctionPointer QLibraryPrivate::resolve_sys(const char* symbol) return QFunctionPointer(address); } QT_END_NAMESPACE - -#endif // QT_NO_LIBRARY diff --git a/src/corelib/plugin/qmachparser.cpp b/src/corelib/plugin/qmachparser.cpp index a599fbcb23..f506a6a6b1 100644 --- a/src/corelib/plugin/qmachparser.cpp +++ b/src/corelib/plugin/qmachparser.cpp @@ -39,7 +39,7 @@ #include "qmachparser_p.h" -#if defined(Q_OF_MACH_O) && !defined(QT_NO_LIBRARY) +#if defined(Q_OF_MACH_O) #include #include "qlibrary_p.h" diff --git a/src/corelib/plugin/qmachparser_p.h b/src/corelib/plugin/qmachparser_p.h index ff7eaadb70..3884c92797 100644 --- a/src/corelib/plugin/qmachparser_p.h +++ b/src/corelib/plugin/qmachparser_p.h @@ -54,7 +54,8 @@ #include #include -#ifndef QT_NO_LIBRARY +QT_REQUIRE_CONFIG(library); + #if defined(Q_OF_MACH_O) QT_BEGIN_NAMESPACE @@ -72,6 +73,5 @@ public: QT_END_NAMESPACE #endif // defined(Q_OF_ELF) && defined(Q_CC_GNU) -#endif // QT_NO_LIBRARY #endif // QMACHPARSER_P_H diff --git a/src/corelib/plugin/qpluginloader.cpp b/src/corelib/plugin/qpluginloader.cpp index 6723877ad5..dbd3bee556 100644 --- a/src/corelib/plugin/qpluginloader.cpp +++ b/src/corelib/plugin/qpluginloader.cpp @@ -49,7 +49,7 @@ QT_BEGIN_NAMESPACE -#ifndef QT_NO_LIBRARY +#if QT_CONFIG(library) /*! \class QPluginLoader @@ -417,7 +417,7 @@ QLibrary::LoadHints QPluginLoader::loadHints() const return d ? d->loadHints() : QLibrary::LoadHints(); } -#endif // QT_NO_LIBRARY +#endif // QT_CONFIG(library) typedef QVector StaticPluginList; Q_GLOBAL_STATIC(StaticPluginList, staticPluginList) diff --git a/src/corelib/plugin/qpluginloader.h b/src/corelib/plugin/qpluginloader.h index 5dca59c271..80b10f76bf 100644 --- a/src/corelib/plugin/qpluginloader.h +++ b/src/corelib/plugin/qpluginloader.h @@ -40,12 +40,15 @@ #ifndef QPLUGINLOADER_H #define QPLUGINLOADER_H +#include +#if QT_CONFIG(library) #include +#endif #include QT_BEGIN_NAMESPACE -#ifndef QT_NO_LIBRARY +#if QT_CONFIG(library) class QLibraryPrivate; class QJsonObject; @@ -93,7 +96,7 @@ public: static QVector staticPlugins(); }; -#endif // QT_NO_LIBRARY +#endif // QT_CONFIG(library) QT_END_NAMESPACE -- cgit v1.2.3