Skip to content
Merged
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
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ jobs:
uses: fcitx/github-actions@cmake
with:
path: fcitx5-beast
cmake-option: >-
-DBUILD_SHARED_FCITX_ADDON=Off

- name: Test
run: |
Expand Down
7 changes: 1 addition & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,9 @@ include(GNUInstallDirs)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

option(ENABLE_TEST "Build Test" On)
set(ADDON_TYPE "StaticLibrary" CACHE STRING "StaticLibrary or SharedLibrary")

if (NOT "${ADDON_TYPE}" MATCHES "^(StaticLibrary|SharedLibrary)$")
message(FATAL_ERROR "ADDON_TYPE must be StaticLibrary or SharedLibrary")
endif()

find_package(Gettext REQUIRED)
find_package(Fcitx5Core 5 REQUIRED)
find_package(Fcitx5Core 5.1.12 REQUIRED)
find_package(Boost 1.83 REQUIRED)

include("${FCITX_INSTALL_CMAKECONFIG_DIR}/Fcitx5Utils/Fcitx5CompilerSettings.cmake")
Expand Down
12 changes: 3 additions & 9 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
if ("${ADDON_TYPE}" STREQUAL "StaticLibrary")
add_library(beast STATIC beast.cpp)
target_link_libraries(beast Fcitx5::Core)
endif()
add_fcitx5_addon(beast beast.cpp)
target_link_libraries(beast Fcitx5::Core)

if ("${ADDON_TYPE}" STREQUAL "SharedLibrary")
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
add_library(beast SHARED beast.cpp)
target_link_libraries(beast Fcitx5::Core)
target_compile_definitions(beast PUBLIC FCITX_BEAST_IS_SHARED)
if ("${FCITX_ADDON_TYPE}" STREQUAL "SharedLibrary")
install(TARGETS beast DESTINATION "${CMAKE_INSTALL_LIBDIR}/fcitx5")
endif()

Expand Down
2 changes: 1 addition & 1 deletion src/beast.conf.in.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ Comment=Interact with fcitx5 via HTTP, powered by Boost.Beast
Category=Module
Version=@PROJECT_VERSION@
Library=libbeast
Type=@ADDON_TYPE@
Type=@FCITX_ADDON_TYPE@
OnDemand=False
Configurable=True
4 changes: 1 addition & 3 deletions src/beast.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,4 @@ void Beast::stopThread() {
}
} // namespace fcitx

#ifdef FCITX_BEAST_IS_SHARED
FCITX_ADDON_FACTORY(fcitx::BeastFactory)
#endif
FCITX_ADDON_FACTORY_V2(beast, fcitx::BeastFactory)
11 changes: 5 additions & 6 deletions test/testbeast.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,18 @@

using namespace fcitx;

FCITX_DEFINE_STATIC_ADDON_REGISTRY(getStaticAddon)
FCITX_IMPORT_ADDON_FACTORY(getStaticAddon, beast);

int main() {
char arg0[] = "testhallelujah";
char arg0[] = "testbeast";
char arg1[] = "--disable=all";
char arg2[] = "--enable=beast";
char *argv[] = {arg0, arg1, arg2};
Log::setLogRule("default=5");

fcitx::BeastFactory beastFactory;
fcitx::StaticAddonRegistry staticAddons = {
std::make_pair<std::string, fcitx::AddonFactory *>("beast",
&beastFactory)};
Instance instance(FCITX_ARRAY_SIZE(argv), argv);
instance.addonManager().registerDefaultLoader(&staticAddons);
instance.addonManager().registerDefaultLoader(&getStaticAddon());
EventDispatcher dispatcher;
dispatcher.attach(&instance.eventLoop());

Expand Down
Loading