Skip to content

Commit

Permalink
Add support for android-build (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
eagleoflqj authored Oct 16, 2023
1 parent 27514b1 commit 0470df3
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 9 deletions.
6 changes: 5 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ include(ECMUninstallTarget)
find_package(Fcitx5Core 5.0.2 REQUIRED)
find_package(Gettext REQUIRED)
find_package(PkgConfig REQUIRED)
pkg_check_modules(Hangul IMPORTED_TARGET "libhangul>=0.0.12" REQUIRED)

if (NOT DEFINED HANGUL_TARGET)
pkg_check_modules(Hangul IMPORTED_TARGET "libhangul>=0.0.12" REQUIRED)
set(HANGUL_TARGET PkgConfig::Hangul)
endif()

include("${FCITX_INSTALL_CMAKECONFIG_DIR}/Fcitx5Utils/Fcitx5CompilerSettings.cmake")
add_definitions(-DFCITX_GETTEXT_DOMAIN=\"fcitx5-hangul\" -D_GNU_SOURCE)
Expand Down
2 changes: 1 addition & 1 deletion data/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
install(FILES symbol.txt DESTINATION ${FCITX_INSTALL_PKGDATADIR}/hangul/)
install(FILES symbol.txt DESTINATION ${FCITX_INSTALL_PKGDATADIR}/hangul/ COMPONENT config)

install(DIRECTORY 16x16 22x22 24x24 48x48 64x64 DESTINATION "${CMAKE_INSTALL_DATADIR}/icons/hicolor"
PATTERN .* EXCLUDE
Expand Down
2 changes: 1 addition & 1 deletion list/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
add_executable(gen_list gen_list.c)
target_link_libraries (gen_list PkgConfig::Hangul)
target_link_libraries (gen_list ${HANGUL_TARGET})
7 changes: 3 additions & 4 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@ set( fcitx_hangul_sources
)

add_library(hangul MODULE ${fcitx_hangul_sources})
target_link_libraries(hangul Fcitx5::Core Fcitx5::Config PkgConfig::Hangul)
set_target_properties(hangul PROPERTIES PREFIX "")
target_link_libraries(hangul Fcitx5::Core Fcitx5::Config ${HANGUL_TARGET})
install(TARGETS hangul DESTINATION "${CMAKE_INSTALL_LIBDIR}/fcitx5")
fcitx5_translate_desktop_file(hangul.conf.in hangul.conf)
configure_file(hangul-addon.conf.in.in hangul-addon.conf.in)
fcitx5_translate_desktop_file("${CMAKE_CURRENT_BINARY_DIR}/hangul-addon.conf.in" hangul-addon.conf)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/hangul.conf" DESTINATION "${FCITX_INSTALL_PKGDATADIR}/inputmethod")
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/hangul-addon.conf" RENAME hangul.conf DESTINATION "${FCITX_INSTALL_PKGDATADIR}/addon")
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/hangul.conf" DESTINATION "${FCITX_INSTALL_PKGDATADIR}/inputmethod" COMPONENT config)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/hangul-addon.conf" RENAME hangul.conf DESTINATION "${FCITX_INSTALL_PKGDATADIR}/addon" COMPONENT config)
13 changes: 12 additions & 1 deletion src/engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -538,10 +538,21 @@ class HangulState : public InputContextProperty {
LookupMethod lastLookupMethod_;
};

HanjaTable *loadTable() {
const auto &sp = fcitx::StandardPath::global();
std::string hanjaTxt =
sp.locate(fcitx::StandardPath::Type::Data, "libhangul/hanja/hanja.txt");
HanjaTable *table = nullptr;
if (!hanjaTxt.empty()) {
table = hanja_table_load(hanjaTxt.c_str());
}
return table ? table : hanja_table_load(nullptr);
}

HangulEngine::HangulEngine(Instance *instance)
: instance_(instance),
factory_([this](InputContext &ic) { return new HangulState(this, &ic); }),
table_(hanja_table_load(nullptr)) {
table_(loadTable()) {
if (!table_) {
throw std::runtime_error("Failed to load hanja table.");
}
Expand Down
2 changes: 1 addition & 1 deletion src/hangul-addon.conf.in.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Name=Hangul
Comment=Hangul Wrapper For Fcitx
Category=InputMethod
Version=@PROJECT_VERSION@
Library=hangul
Library=libhangul
Type=SharedLibrary
OnDemand=True
Configurable=True

0 comments on commit 0470df3

Please sign in to comment.