Fix CTF with static build

- Do not require feature library
- Load static plugin

Change-Id: I6c3ec72e20b9f2800c1d350dac795fccbb8c381e
Reviewed-by: Janne Koskinen <janne.p.koskinen@qt.io>
Reviewed-by: Antti Määttä <antti.maatta@qt.io>
This commit is contained in:
Antti Määttä 2023-10-05 14:48:14 +03:00
parent 457566c96f
commit 0f2558470d
5 changed files with 30 additions and 6 deletions

View File

@ -1341,7 +1341,7 @@ qt_internal_extend_target(Core CONDITION WASM
kernel/qeventdispatcher_wasm.cpp kernel/qeventdispatcher_wasm_p.h
)
qt_internal_extend_target(Core CONDITION QT_FEATURE_ctf AND QT_FEATURE_library
qt_internal_extend_target(Core CONDITION QT_FEATURE_ctf
SOURCES
tracing/qctf_p.h tracing/qctf.cpp
PLUGIN_TYPES

View File

@ -7,6 +7,7 @@
#include <qpluginloader.h>
#include <qfileinfo.h>
#include <qdir.h>
#include <qjsonarray.h>
#include "qctf_p.h"
@ -18,6 +19,8 @@ static bool s_prevent_recursion = false;
static bool s_shutdown = false;
static QCtfLib* s_plugin = nullptr;
#if QT_CONFIG(library) && defined(QT_SHARED)
#if defined(Q_OS_ANDROID)
static QString findPlugin(const QString &plugin)
{
@ -64,6 +67,30 @@ static bool loadPlugin(bool &retry)
return true;
}
#else
#define QCtfPluginIID QStringLiteral("org.qt-project.Qt.QCtfLib")
static bool loadPlugin(bool &retry)
{
retry = false;
const auto &plugins = QPluginLoader::staticPlugins();
for (const auto &plugin : plugins) {
const auto json = plugin.metaData();
const auto IID = json[QStringLiteral("IID")];
if (IID.toString() == QCtfPluginIID) {
s_plugin = qobject_cast<QCtfLib *>(plugin.instance());
if (!s_plugin)
return false;
s_plugin->shutdown(&s_shutdown);
return true;
}
}
return false;
}
#endif
static bool initialize()
{
if (s_shutdown || s_prevent_recursion)

View File

@ -19,8 +19,6 @@
#include <qtcoreexports.h>
#include <qobject.h>
QT_REQUIRE_CONFIG(library);
QT_BEGIN_NAMESPACE
struct QCtfTraceMetadata;

View File

@ -25,6 +25,6 @@ if (TARGET Qt::Network)
add_subdirectory(networkinformation)
add_subdirectory(tls)
endif()
if (QT_FEATURE_ctf AND QT_FEATURE_library)
if (QT_FEATURE_ctf AND TARGET Qt::Network)
add_subdirectory(tracing)
endif()

View File

@ -12,14 +12,13 @@ endfunction(make_includable)
make_includable(metadata_template.txt metadata_template.h)
qt_internal_add_plugin(QCtfTracePlugin
SHARED
CLASS_NAME QCtfTracePlugin
PLUGIN_TYPE tracing
SOURCES
qctflib_p.h qctflib.cpp metadata_template.txt qctfplugin.cpp qctfplugin_p.h
qctfserver_p.h qctfserver.cpp
LIBRARIES
Qt6::Core Qt6::CorePrivate Qt6::Network
Qt::Core Qt::CorePrivate Qt::Network
)
qt_internal_extend_target(QCtfTracePlugin CONDITION QT_FEATURE_zstd