Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ option(ENABLE_EMOJI "Enable emoji module" On)
option(ENABLE_LIBUUID "Use libuuid for uuid generation" On)
option(BUILD_SPELL_DICT "Build en_dict.fscd for English spell check" On)
option(BUILD_SHARED_LIBS "Build library as shared libs" On)
option(ENABLE_DL "Enable dynamic loading addons" On)
option(USE_SYSTEM_YOGA "Use system installed yoga library" Off)
set(NO_PREEDIT_APPS "gvim.*,wps.*,wpp.*,et.*" CACHE STRING "Disable preedit for following app by default.")
set(EVENT_LOOP_BACKEND "auto" CACHE STRING "Set the underlying event loop implementation, valid values are auto,systemd,libuv,none")
Expand Down Expand Up @@ -119,7 +120,10 @@ endif()
if(${CMAKE_SYSTEM_NAME} MATCHES "BSD|DragonFly")
find_package(LibKVM REQUIRED)
endif()
find_package(DL REQUIRED)

if (ENABLE_DL)
find_package(DL REQUIRED)
endif()

if (NOT TARGET LibIntl::LibIntl)
find_package(LibIntl REQUIRED)
Expand Down
12 changes: 9 additions & 3 deletions src/lib/fcitx-utils/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ list(APPEND FCITX_UTILS_SOURCES
color.cpp
i18nstring.cpp
eventdispatcher.cpp
library.cpp
fs.cpp
fs_deprecated.cpp
standardpath.cpp
Expand Down Expand Up @@ -90,7 +89,6 @@ set(FCITX_UTILS_HEADERS
event.h
eventloopinterface.h
eventdispatcher.h
library.h
cutf8.h
fs.h
standardpath.h
Expand Down Expand Up @@ -125,6 +123,11 @@ set(FCITX_UTILS_HEADERS
${CMAKE_CURRENT_BINARY_DIR}/fcitxutils_export.h
)

if (ENABLE_DL)
list(APPEND FCITX_UTILS_SOURCES library.cpp)
list(APPEND FCITX_UTILS_HEADERS library.h)
endif()

set(FCITX_UTILS_DBUS_HEADERS
dbus/message.h
dbus/objectvtable.h
Expand All @@ -150,10 +153,13 @@ target_include_directories(Fcitx5Utils PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/..>
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/..>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_FULL_INCLUDEDIR}/Fcitx5/Utils>)
target_link_libraries(Fcitx5Utils PRIVATE DL::DL LibIntl::LibIntl Pthread::Pthread)
target_link_libraries(Fcitx5Utils PRIVATE LibIntl::LibIntl Pthread::Pthread)
if(LIBKVM_FOUND)
target_link_libraries(Fcitx5Utils PRIVATE LibKVM::LibKVM)
endif()
if (ENABLE_DL)
target_link_libraries(Fcitx5Utils PRIVATE DL::DL)
endif()
target_link_libraries(Fcitx5Utils PRIVATE ${FCITX_UTILS_DEPS})

configure_file(Fcitx5Utils.pc.in ${CMAKE_CURRENT_BINARY_DIR}/Fcitx5Utils.pc @ONLY)
Expand Down
4 changes: 4 additions & 0 deletions src/lib/fcitx/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ if (ENABLE_LIBUUID)
target_link_libraries(Fcitx5Core PRIVATE LibUUID::LibUUID)
endif()

if (NOT ENABLE_DL)
target_compile_definitions(Fcitx5Core PRIVATE -DFCITX_NO_DL)
endif()

configure_file(Fcitx5Core.pc.in ${CMAKE_CURRENT_BINARY_DIR}/Fcitx5Core.pc @ONLY)

install(TARGETS Fcitx5Core EXPORT Fcitx5CoreTargets LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}")
Expand Down
4 changes: 4 additions & 0 deletions src/lib/fcitx/addonloader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
#include <utility>
#include <vector>
#include "fcitx-utils/flags.h"
#ifndef FCITX_NO_DL
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move this down to its own section, otherwise formatter won't sort the include before and after.

#include "fcitx-utils/library.h"
#endif
#include "fcitx-utils/log.h"
#include "fcitx-utils/standardpaths.h"
#include "fcitx-utils/stringutils.h"
Expand All @@ -27,6 +29,7 @@ namespace fcitx {

AddonLoader::~AddonLoader() {}

#ifndef FCITX_NO_DL
SharedLibraryLoader::~SharedLibraryLoader() {}

AddonInstance *SharedLibraryLoader::load(const AddonInfo &info,
Expand Down Expand Up @@ -100,6 +103,7 @@ AddonInstance *SharedLibraryLoader::load(const AddonInfo &info,
}
return nullptr;
}
#endif

StaticLibraryLoader::StaticLibraryLoader(StaticAddonRegistry *registry_)
: registry(registry_) {}
Expand Down
4 changes: 4 additions & 0 deletions src/lib/fcitx/addonloader_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
#include <unordered_map>
#include <utility>
#include <vector>
#ifndef FCITX_NO_DL
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might make it cleaner if you move shared library loader to its own file

#include <fcitx-utils/library.h>
#endif
#include <fcitx-utils/standardpaths.h>
#include <fcitx-utils/stringutils.h>
#include <fcitx/addonfactory.h>
Expand All @@ -27,6 +29,7 @@ namespace {
constexpr char FCITX_ADDON_FACTORY_ENTRY[] = "fcitx_addon_factory_instance";
}

#ifndef FCITX_NO_DL
class SharedLibraryFactory {
public:
SharedLibraryFactory(const AddonInfo &info, std::vector<Library> libraries)
Expand Down Expand Up @@ -71,6 +74,7 @@ class SharedLibraryLoader : public AddonLoader {
std::unordered_map<std::string, std::unique_ptr<SharedLibraryFactory>>
registry_;
};
#endif

class StaticLibraryLoader : public AddonLoader {
public:
Expand Down
2 changes: 2 additions & 0 deletions src/lib/fcitx/addonmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,9 @@ void AddonManager::unregisterLoader(const std::string &name) {
}

void AddonManager::registerDefaultLoader(StaticAddonRegistry *registry) {
#ifndef FCITX_NO_DL
registerLoader(std::make_unique<SharedLibraryLoader>());
#endif
if (registry) {
registerLoader(std::make_unique<StaticLibraryLoader>(registry));
}
Expand Down
Loading