Skip to content

Commit

Permalink
use FCITX_DEFINE_STATIC_ADDON_REGISTRY (#214)
Browse files Browse the repository at this point in the history
  • Loading branch information
eagleoflqj authored Dec 9, 2024
1 parent 6b5fbc5 commit 1697019
Show file tree
Hide file tree
Showing 11 changed files with 30 additions and 26 deletions.
11 changes: 6 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -90,16 +90,17 @@ add_compile_definitions($<$<COMPILE_LANGUAGE:C,CXX>:-DFCITX_GETTEXT_DOMAIN=\"fci
add_subdirectory(keycode)
add_subdirectory(macosfrontend)
add_subdirectory(macosnotifications)
add_subdirectory(webpanel)

add_subdirectory(src)
add_subdirectory(assets)

option(BUILD_PREVIEW "" OFF)
add_subdirectory(fcitx5-webview)
add_subdirectory(webpanel)

set(ADDON_TYPE "StaticLibrary")
set(BUILD_SHARED_FCITX_ADDON OFF)
include(fcitx5/src/lib/fcitx-utils/Fcitx5Macros.cmake)
add_subdirectory(fcitx5-beast/src)

add_subdirectory(src)
add_subdirectory(assets)

enable_testing()
add_subdirectory(tests)
2 changes: 1 addition & 1 deletion deps/url-filter
2 changes: 1 addition & 1 deletion fcitx5
Submodule fcitx5 updated 59 files
+2 −1 CMakeLists.txt
+13 −3 src/CMakeLists.txt
+1 −1 src/frontend/dbusfrontend/CMakeLists.txt
+1 −1 src/frontend/dbusfrontend/dbusfrontend.conf.in.in
+1 −1 src/frontend/fcitx4frontend/CMakeLists.txt
+1 −1 src/frontend/fcitx4frontend/fcitx4frontend.conf.in.in
+1 −1 src/frontend/ibusfrontend/CMakeLists.txt
+1 −1 src/frontend/ibusfrontend/ibusfrontend.conf.in.in
+1 −1 src/frontend/waylandim/CMakeLists.txt
+1 −1 src/frontend/waylandim/waylandim.conf.in.in
+1 −1 src/frontend/xim/CMakeLists.txt
+1 −1 src/frontend/xim/xim.conf.in.in
+1 −1 src/lib/fcitx-config/CMakeLists.txt
+1 −1 src/lib/fcitx-utils/CMakeLists.txt
+60 −0 src/lib/fcitx-utils/Fcitx5Macros.cmake
+1 −1 src/lib/fcitx/CMakeLists.txt
+10 −4 src/lib/fcitx/addoninstance.h
+7 −10 src/lib/fcitx/instance.cpp
+10 −0 src/lib/fcitx/userinterfacemanager.cpp
+1 −1 src/modules/clipboard/CMakeLists.txt
+1 −1 src/modules/clipboard/clipboard.conf.in.in
+1 −1 src/modules/dbus/CMakeLists.txt
+1 −1 src/modules/dbus/dbus.conf.in.in
+1 −1 src/modules/emoji/CMakeLists.txt
+1 −1 src/modules/emoji/emoji.conf.in.in
+1 −1 src/modules/imselector/CMakeLists.txt
+1 −1 src/modules/imselector/imselector.conf.in.in
+1 −1 src/modules/notificationitem/CMakeLists.txt
+1 −1 src/modules/notificationitem/notificationitem.conf.in.in
+1 −1 src/modules/notifications/CMakeLists.txt
+1 −1 src/modules/notifications/notifications.conf.in.in
+4 −3 src/modules/notifications/notifications.cpp
+3 −2 src/modules/notifications/notifications.h
+1 −1 src/modules/quickphrase/CMakeLists.txt
+1 −1 src/modules/quickphrase/quickphrase.conf.in.in
+1 −1 src/modules/spell/CMakeLists.txt
+1 −1 src/modules/spell/spell.conf.in.in
+1 −1 src/modules/unicode/CMakeLists.txt
+1 −1 src/modules/unicode/unicode.conf.in.in
+1 −1 src/modules/wayland/CMakeLists.txt
+1 −1 src/modules/wayland/wayland.conf.in.in
+1 −1 src/modules/xcb/CMakeLists.txt
+1 −1 src/modules/xcb/xcb.conf.in.in
+1 −0 src/server/CMakeLists.txt
+3 −3 src/server/main.cpp
+1 −1 src/ui/classic/CMakeLists.txt
+1 −1 src/ui/classic/classicui.conf.in.in
+1 −1 src/ui/kimpanel/CMakeLists.txt
+1 −1 src/ui/kimpanel/kimpanel.conf.in.in
+1 −1 src/ui/virtualkeyboard/CMakeLists.txt
+1 −1 src/ui/virtualkeyboard/virtualkeyboard.conf.in.in
+14 −2 src/ui/virtualkeyboard/virtualkeyboard.cpp
+1 −0 src/ui/virtualkeyboard/virtualkeyboard.h
+2 −2 test/addon/CMakeLists.txt
+2 −2 test/testcompose.cpp
+2 −2 test/testspell.cpp
+1 −1 testing/testfrontend/CMakeLists.txt
+1 −1 testing/testim/CMakeLists.txt
+1 −1 testing/testui/CMakeLists.txt
2 changes: 1 addition & 1 deletion fcitx5-beast
2 changes: 1 addition & 1 deletion fcitx5-webview
2 changes: 1 addition & 1 deletion keycode/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
add_library(Keycode keycode.cpp)
add_library(Keycode STATIC keycode.cpp)
target_include_directories(Keycode PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}")
target_link_libraries(Keycode Fcitx5::Utils)
2 changes: 1 addition & 1 deletion logging/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ else()
endif()
configure_file(debug.swift.in ${CMAKE_CURRENT_SOURCE_DIR}/debug.swift @ONLY)

add_library(Logging logging.swift debug.swift)
add_library(Logging STATIC logging.swift debug.swift)
8 changes: 4 additions & 4 deletions macosnotifications/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ _swift_generate_cxx_header(
DEPENDS Logging
)

add_library(macosnotifications STATIC macosnotifications.cpp)
add_dependencies(macosnotifications SwiftNotify)
target_link_libraries(macosnotifications Fcitx5::Core Fcitx5::Module::Notifications)
target_include_directories(macosnotifications PUBLIC
add_library(notifications STATIC macosnotifications.cpp)
add_dependencies(notifications SwiftNotify)
target_link_libraries(notifications Fcitx5::Core Fcitx5::Module::Notifications)
target_include_directories(notifications PUBLIC
"${CMAKE_CURRENT_BINARY_DIR}/include"
"${CMAKE_SOURCE_DIR}/src"
)
Expand Down
7 changes: 6 additions & 1 deletion scripts/check-validity.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ set -e

has_homebrew_deps=0
has_xcode_rpath=0
has_extra_dylib=0

cd /Library/Input\ Methods/Fcitx5.app/Contents
libs=(MacOS/Fcitx5)
Expand All @@ -18,6 +19,10 @@ for lib in "${libs[@]}"; do
otool -l $lib | grep -A2 LC_RPATH
has_xcode_rpath=2
fi
n_dylib=$(otool -L MacOS/Fcitx5 | grep rpath | wc -l | xargs)
if [[ $n_dylib != 3 ]]; then
has_extra_dylib=4
fi
done

exit $((has_homebrew_deps + has_xcode_rpath))
exit $((has_homebrew_deps + has_xcode_rpath + has_extra_dylib))
7 changes: 6 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ target_link_libraries(Fcitx5Objs
webpanel
beast
macosfrontend
macosnotifications
notifications
WebviewCandidateWindow
Logging
)
Expand All @@ -46,6 +46,11 @@ target_link_libraries(Fcitx5
SwiftNotify
)

fcitx5_import_addons(Fcitx5
REGISTRY_VARNAME getStaticAddon
ADDONS beast keyboard webpanel macosfrontend notifications
)

set(APP_PATH "${CMAKE_CURRENT_BINARY_DIR}/Fcitx5.app/Contents")

set(BINARY_LIB_PATH "${PROJECT_BINARY_DIR}/fcitx5/src/lib")
Expand Down
11 changes: 2 additions & 9 deletions src/fcitx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,7 @@ namespace fs = std::filesystem;

#define APP_CONTENTS_PATH "/Library/Input Methods/Fcitx5.app/Contents"

fcitx::BeastFactory beastFactory;
fcitx::StaticAddonRegistry staticAddons = {
std::make_pair<std::string, fcitx::AddonFactory *>("beast", &beastFactory)};

FCITX_IMPORT_ADDON_FACTORY(staticAddons, keyboard);
FCITX_IMPORT_ADDON_FACTORY(staticAddons, webpanel);
FCITX_IMPORT_ADDON_FACTORY(staticAddons, macosfrontend);
FCITX_IMPORT_ADDON_FACTORY(staticAddons, notifications);
FCITX_DEFINE_STATIC_ADDON_REGISTRY(getStaticAddon)

static std::string join_paths(const std::vector<fs::path> &paths,
char sep = ':');
Expand Down Expand Up @@ -139,7 +132,7 @@ void Fcitx::setupInstance() {
instance_ = std::make_unique<fcitx::Instance>(0, nullptr);
dispatcher_ = std::make_unique<fcitx::EventDispatcher>();
auto &addonMgr = instance_->addonManager();
addonMgr.registerDefaultLoader(&staticAddons);
addonMgr.registerDefaultLoader(&getStaticAddon());
instance_->initialize();
dispatcher_->attach(&instance_->eventLoop());
}
Expand Down

0 comments on commit 1697019

Please sign in to comment.