fix: Make sure library plugins are always initialized
This commit is contained in:
parent
f44b44a881
commit
5adeac6bbc
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include <hex.hpp>
|
#include <hex.hpp>
|
||||||
#include <hex/api/plugin_manager.hpp>
|
#include <hex/api/plugin_manager.hpp>
|
||||||
|
#include <hex/helpers/logger.hpp>
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
@ -26,6 +27,11 @@
|
|||||||
|
|
||||||
#define IMHEX_LIBRARY_SETUP_IMPL() \
|
#define IMHEX_LIBRARY_SETUP_IMPL() \
|
||||||
IMHEX_PLUGIN_VISIBILITY_PREFIX void initializeLibrary(); \
|
IMHEX_PLUGIN_VISIBILITY_PREFIX void initializeLibrary(); \
|
||||||
|
static auto WOLV_TOKEN_CONCAT(libraryInitializer_, IMHEX_PLUGIN_NAME) = [] { \
|
||||||
|
initializeLibrary(); \
|
||||||
|
hex::log::info("Library plugin '{}' initialized successfully", WOLV_STRINGIFY(IMHEX_PLUGIN_NAME)); \
|
||||||
|
return 0; \
|
||||||
|
}(); \
|
||||||
extern "C" [[gnu::visibility("default")]] void WOLV_TOKEN_CONCAT(forceLinkPlugin_, IMHEX_PLUGIN_NAME)() { \
|
extern "C" [[gnu::visibility("default")]] void WOLV_TOKEN_CONCAT(forceLinkPlugin_, IMHEX_PLUGIN_NAME)() { \
|
||||||
hex::PluginManager::addPlugin(hex::PluginFunctions { \
|
hex::PluginManager::addPlugin(hex::PluginFunctions { \
|
||||||
nullptr, \
|
nullptr, \
|
||||||
|
@ -17,6 +17,8 @@
|
|||||||
namespace hex {
|
namespace hex {
|
||||||
|
|
||||||
Plugin::Plugin(const std::fs::path &path) : m_path(path) {
|
Plugin::Plugin(const std::fs::path &path) : m_path(path) {
|
||||||
|
log::info("Loading plugin '{}'", wolv::util::toUTF8String(path.filename()));
|
||||||
|
|
||||||
#if defined(OS_WINDOWS)
|
#if defined(OS_WINDOWS)
|
||||||
m_handle = uintptr_t(LoadLibraryW(path.c_str()));
|
m_handle = uintptr_t(LoadLibraryW(path.c_str()));
|
||||||
|
|
||||||
@ -33,8 +35,6 @@ namespace hex {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
log::info("Loaded plugin '{}'", wolv::util::toUTF8String(path.filename()));
|
|
||||||
|
|
||||||
m_functions.initializePluginFunction = getPluginFunction<PluginFunctions::InitializePluginFunc>("initializePlugin");
|
m_functions.initializePluginFunction = getPluginFunction<PluginFunctions::InitializePluginFunc>("initializePlugin");
|
||||||
m_functions.initializeLibraryFunction = getPluginFunction<PluginFunctions::InitializePluginFunc>("initializeLibrary");
|
m_functions.initializeLibraryFunction = getPluginFunction<PluginFunctions::InitializePluginFunc>("initializeLibrary");
|
||||||
m_functions.getPluginNameFunction = getPluginFunction<PluginFunctions::GetPluginNameFunc>("getPluginName");
|
m_functions.getPluginNameFunction = getPluginFunction<PluginFunctions::GetPluginNameFunc>("getPluginName");
|
||||||
@ -88,8 +88,6 @@ namespace hex {
|
|||||||
const auto pluginName = wolv::util::toUTF8String(m_path.filename());
|
const auto pluginName = wolv::util::toUTF8String(m_path.filename());
|
||||||
|
|
||||||
if (this->isLibraryPlugin()) {
|
if (this->isLibraryPlugin()) {
|
||||||
m_functions.initializeLibraryFunction();
|
|
||||||
log::info("Library plugin '{}' initialized successfully", pluginName);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user