Fix static linking when bearer management plugins are built

The bearer plugins include copies of moc generated code that results in
duplicate symbols when static linking pulls in multiple bearer plugins.
Instead of relying on toolchain defined behavior, this patch moves the
code that is shared into the shared library as private API. This way it
will exist only once in memory and once at link time, resulting no
linking errors about duplicate symbols.

Fixes: QTBUG-79211
Change-Id: Iafa45c234e7fdd998971fc9cb7116334d08907bc
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
This commit is contained in:
Simon Hausmann 2019-10-14 15:18:44 +02:00
parent 3026c0630d
commit 5f160a3699
25 changed files with 46 additions and 52 deletions

View File

@ -6,11 +6,14 @@ HEADERS += bearer/qnetworkconfiguration.h \
bearer/qnetworkconfigmanager_p.h \
bearer/qnetworkconfiguration_p.h \
bearer/qnetworksession_p.h \
bearer/qnetworksession_impl_p.h \
bearer/qbearerengine_p.h \
bearer/qbearerengine_impl_p.h \
bearer/qbearerplugin_p.h \
bearer/qsharednetworksession_p.h
SOURCES += bearer/qnetworksession.cpp \
bearer/qnetworksession_impl.cpp \
bearer/qnetworkconfigmanager.cpp \
bearer/qnetworkconfiguration.cpp \
bearer/qnetworkconfigmanager_p.cpp \

View File

@ -42,9 +42,11 @@
#include <QtNetwork/private/qbearerengine_p.h>
#ifndef QT_NO_BEARERMANAGEMENT
QT_BEGIN_NAMESPACE
class QBearerEngineImpl : public QBearerEngine
class Q_NETWORK_EXPORT QBearerEngineImpl : public QBearerEngine
{
Q_OBJECT
@ -78,4 +80,6 @@ QT_END_NAMESPACE
Q_DECLARE_METATYPE(QBearerEngineImpl::ConnectionError)
#endif // QT_NO_BEARERMANAGEMENT
#endif // QBEARERENGINE_IMPL_H

View File

@ -40,8 +40,8 @@
// see comment in ../platformdefs_win.h.
#define WIN32_LEAN_AND_MEAN 1
#include "qnetworksession_impl.h"
#include "qbearerengine_impl.h"
#include "qnetworksession_impl_p.h"
#include "qbearerengine_impl_p.h"
#include <QtNetwork/qnetworksession.h>
#include <QtNetwork/private/qnetworkconfigmanager_p.h>
@ -51,6 +51,8 @@
#include <QtCore/qmutex.h>
#include <QtCore/qstringlist.h>
#ifndef QT_NO_BEARERMANAGEMENT
QT_BEGIN_NAMESPACE
static QBearerEngineImpl *getEngineFromId(const QString &id)
@ -433,3 +435,5 @@ void QNetworkSessionPrivateImpl::decrementTimeout()
QT_END_NAMESPACE
#include "qnetworksession_impl.moc"
#endif // QT_NO_BEARERMANAGEMENT

View File

@ -51,16 +51,18 @@
// We mean it.
//
#include "qbearerengine_impl.h"
#include "qbearerengine_impl_p.h"
#include <QtNetwork/private/qnetworkconfigmanager_p.h>
#include <QtNetwork/private/qnetworksession_p.h>
#ifndef QT_NO_BEARERMANAGEMENT
QT_BEGIN_NAMESPACE
class QBearerEngineImpl;
class QNetworkSessionPrivateImpl : public QNetworkSessionPrivate
class Q_NETWORK_EXPORT QNetworkSessionPrivateImpl : public QNetworkSessionPrivate
{
Q_OBJECT
@ -127,4 +129,6 @@ private:
QT_END_NAMESPACE
#endif // QT_NO_BEARERMANAGEMENT
#endif // QNETWORKSESSION_IMPL_H

View File

@ -38,7 +38,7 @@
****************************************************************************/
#include "qandroidbearerengine.h"
#include "../../qnetworksession_impl.h"
#include <private/qnetworksession_impl_p.h>
#include "wrappers/androidconnectivitymanager.h"
#ifndef QT_NO_BEARERMANAGEMENT

View File

@ -40,7 +40,7 @@
#ifndef QANDROIDBEARERENGINE_H
#define QANDROIDBEARERENGINE_H
#include "../../qbearerengine_impl.h"
#include <private/qbearerengine_impl_p.h>
#include <QAbstractEventDispatcher>
#include <QAbstractNativeEventFilter>

View File

@ -2,13 +2,10 @@ TARGET = qandroidbearer
QT = core-private network-private
HEADERS += qandroidbearerengine.h \
../../qnetworksession_impl.h \
../../qbearerengine_impl.h
HEADERS += qandroidbearerengine.h
SOURCES += main.cpp \
qandroidbearerengine.cpp \
../../qnetworksession_impl.cpp
qandroidbearerengine.cpp
include(wrappers/wrappers.pri)

View File

@ -4,15 +4,12 @@ QT = core network-private dbus
HEADERS += qconnmanservice_linux_p.h \
../linux_common/qofonoservice_linux_p.h \
qconnmanengine.h \
../qnetworksession_impl.h \
../qbearerengine_impl.h
qconnmanengine.h
SOURCES += main.cpp \
qconnmanservice_linux.cpp \
../linux_common/qofonoservice_linux.cpp \
qconnmanengine.cpp \
../qnetworksession_impl.cpp
qconnmanengine.cpp
OTHER_FILES += connman.json

View File

@ -39,7 +39,7 @@
#include "qconnmanengine.h"
#include "qconnmanservice_linux_p.h"
#include "../qnetworksession_impl.h"
#include <private/qnetworksession_impl_p.h>
#include <QtNetwork/private/qnetworkconfiguration_p.h>

View File

@ -51,7 +51,7 @@
// We mean it.
//
#include "../qbearerengine_impl.h"
#include <private/qbearerengine_impl_p.h>
#include "qconnmanservice_linux_p.h"
#include "../linux_common/qofonoservice_linux_p.h"

View File

@ -7,12 +7,9 @@ qtConfig(corewlan) {
LIBS += -framework CoreWLAN -framework Security
}
HEADERS += qcorewlanengine.h \
../qnetworksession_impl.h \
../qbearerengine_impl.h
HEADERS += qcorewlanengine.h
SOURCES += main.cpp \
../qnetworksession_impl.cpp
SOURCES += main.cpp
OBJECTIVE_SOURCES += qcorewlanengine.mm

View File

@ -40,7 +40,7 @@
#ifndef QCOREWLANENGINE_H
#define QCOREWLANENGINE_H
#include "../qbearerengine_impl.h"
#include <private/qbearerengine_impl_p.h>
#include <QMap>
#include <QTimer>

View File

@ -38,7 +38,7 @@
****************************************************************************/
#include "qcorewlanengine.h"
#include "../qnetworksession_impl.h"
#include <private/qnetworksession_impl_p.h>
#include <QtNetwork/private/qnetworkconfiguration_p.h>

View File

@ -3,11 +3,8 @@ TARGET = qgenericbearer
QT = core-private network-private
HEADERS += qgenericengine.h \
../qnetworksession_impl.h \
../qbearerengine_impl.h \
../platformdefs_win.h
SOURCES += qgenericengine.cpp \
../qnetworksession_impl.cpp \
main.cpp
OTHER_FILES += generic.json

View File

@ -41,7 +41,7 @@
#define WIN32_LEAN_AND_MEAN 1
#include "qgenericengine.h"
#include "../qnetworksession_impl.h"
#include <private/qnetworksession_impl_p.h>
#include <QtNetwork/private/qnetworkconfiguration_p.h>

View File

@ -40,7 +40,7 @@
#ifndef QGENERICENGINE_H
#define QGENERICENGINE_H
#include "../qbearerengine_impl.h"
#include <private/qbearerengine_impl_p.h>
#include <QMap>
#include <QTimer>

View File

@ -3,13 +3,10 @@ TARGET = qnativewifibearer
QT = core-private network-private
HEADERS += qnativewifiengine.h \
platformdefs.h \
../qnetworksession_impl.h \
../qbearerengine_impl.h
platformdefs.h
SOURCES += main.cpp \
qnativewifiengine.cpp \
../qnetworksession_impl.cpp
qnativewifiengine.cpp
OTHER_FILES += nativewifi.json

View File

@ -39,7 +39,7 @@
#include "qnativewifiengine.h"
#include "platformdefs.h"
#include "../qnetworksession_impl.h"
#include <private/qnetworksession_impl_p.h>
#include <QtNetwork/private/qnetworkconfiguration_p.h>

View File

@ -51,7 +51,7 @@
// We mean it.
//
#include "../qbearerengine_impl.h"
#include <private/qbearerengine_impl_p.h>
#include <QtCore/qtimer.h>

View File

@ -4,15 +4,12 @@ QT = core network-private dbus
HEADERS += qnetworkmanagerservice.h \
qnetworkmanagerengine.h \
../linux_common/qofonoservice_linux_p.h \
../qnetworksession_impl.h \
../qbearerengine_impl.h
../linux_common/qofonoservice_linux_p.h
SOURCES += main.cpp \
qnetworkmanagerservice.cpp \
qnetworkmanagerengine.cpp \
../linux_common/qofonoservice_linux.cpp \
../qnetworksession_impl.cpp
../linux_common/qofonoservice_linux.cpp
OTHER_FILES += networkmanager.json

View File

@ -39,7 +39,7 @@
#include "qnetworkmanagerengine.h"
#include "qnetworkmanagerservice.h"
#include "../qnetworksession_impl.h"
#include <private/qnetworksession_impl_p.h>
#include <QtNetwork/private/qnetworkconfiguration_p.h>

View File

@ -51,7 +51,7 @@
// We mean it.
//
#include "../qbearerengine_impl.h"
#include <private/qbearerengine_impl_p.h>
#include "qnetworkmanagerservice.h"

View File

@ -5,13 +5,10 @@ QT = core core-private network network-private
QMAKE_USE_PRIVATE += ws2_32
HEADERS += qnlaengine.h \
../platformdefs_win.h \
../qnetworksession_impl.h \
../qbearerengine_impl.h
../platformdefs_win.h
SOURCES += main.cpp \
qnlaengine.cpp \
../qnetworksession_impl.cpp
qnlaengine.cpp
OTHER_FILES += nla.json

View File

@ -38,7 +38,7 @@
****************************************************************************/
#include "qnlaengine.h"
#include "../qnetworksession_impl.h"
#include <private/qnetworksession_impl_p.h>
#include <QtNetwork/private/qnetworkconfiguration_p.h>

View File

@ -51,7 +51,7 @@
// We mean it.
//
#include "../qbearerengine_impl.h"
#include <private/qbearerengine_impl_p.h>
#include <QtNetwork/private/qnativesocketengine_p.h>