Skip to content

Commit

Permalink
replace pkgconfig
Browse files Browse the repository at this point in the history
  • Loading branch information
eagleoflqj committed Nov 14, 2024
1 parent 490c55a commit b91e300
Show file tree
Hide file tree
Showing 9 changed files with 77 additions and 106 deletions.
41 changes: 37 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,10 @@ set(KEYBOARD_NAME "Keyboard")
set(KEYBOARD_LANGUAGE "zh-Hans")

set(FIND_ROOT_PATH "${PROJECT_BINARY_DIR}/sysroot/usr")
set(PREBUILDER_INCLUDE_DIR "${FIND_ROOT_PATH}/include")
set(PREBUILDER_LIB_DIR "${FIND_ROOT_PATH}/lib")
set(PREBUILDER_SHARE_DIR "${FIND_ROOT_PATH}/share")

set(ENV{PKG_CONFIG_PATH} "${PREBUILDER_LIB_DIR}/pkgconfig")

list(APPEND CMAKE_FIND_ROOT_PATH "${FIND_ROOT_PATH}")

add_subdirectory(deps)
Expand All @@ -59,6 +58,13 @@ find_host_package(PkgConfig)
find_host_package(Gettext)
find_host_package(nlohmann_json)

add_library(Libuv_static STATIC IMPORTED)
set_target_properties(Libuv_static PROPERTIES
IMPORTED_LOCATION "${PREBUILDER_LIB_DIR}/libuv.a"
INTERFACE_INCLUDE_DIRECTORIES "${PREBUILDER_INCLUDE_DIR}"
)
set(LIBUV_TARGET Libuv_static)

add_subdirectory(fcitx5)

add_subdirectory(protocol)
Expand Down Expand Up @@ -90,6 +96,19 @@ function(copy_to_app cmd file relative_path)
endfunction()

if (HALLELUJAH)
add_library(Marisa_static STATIC IMPORTED)
set_target_properties(Marisa_static PROPERTIES
IMPORTED_LOCATION "${PREBUILDER_LIB_DIR}/libmarisa.a"
INTERFACE_INCLUDE_DIRECTORIES "${PREBUILDER_INCLUDE_DIR}"
)
set(MARISA_TARGET Marisa_static)
add_library(JsonC_static STATIC IMPORTED)
set_target_properties(JsonC_static PROPERTIES
IMPORTED_LOCATION "${PREBUILDER_LIB_DIR}/libjson-c.a"
INTERFACE_INCLUDE_DIRECTORIES "${PREBUILDER_INCLUDE_DIR}"
)
set(JSONC_TARGET JsonC_static)

add_definitions(-DHALLELUJAH)
add_subdirectory(engines/fcitx5-hallelujah)
list(APPEND ADDONS hallelujah)
Expand All @@ -98,8 +117,22 @@ endif()
if (RIME)
# RIME_DATA_DIR is not actually used but must exist.
set(RIME_DATA_DIR "/usr/share/rime-data")
set(RIME_TARGET "${PREBUILDER_LIB_DIR}/librime.a" "-L${PREBUILDER_LIB_DIR}" leveldb yaml-cpp marisa opencc glog)
set(Rime_VERSION "1.11.2")
set(Rime_dependencies
"${PREBUILDER_LIB_DIR}/libleveldb.a"
"${PREBUILDER_LIB_DIR}/libyaml-cpp.a"
"${PREBUILDER_LIB_DIR}/libmarisa.a"
"${PREBUILDER_LIB_DIR}/libopencc.a"
"${PREBUILDER_LIB_DIR}/libglog.a"
)
add_library(Rime_static STATIC IMPORTED)
set_target_properties(Rime_static PROPERTIES
IMPORTED_LOCATION "${PREBUILDER_LIB_DIR}/librime.a"
INTERFACE_INCLUDE_DIRECTORIES "${PREBUILDER_INCLUDE_DIR}"
INTERFACE_LINK_LIBRARIES "${Rime_dependencies}"
)
set(RIME_TARGET Rime_static)
set(Rime_VERSION "1.12")

add_definitions(-DRIME)
add_subdirectory(engines/fcitx5-rime)
list(APPEND ADDONS rime)
Expand Down
4 changes: 2 additions & 2 deletions common/common.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "common.h"
#include "../engines/fcitx5-hallelujah/src/hallelujah.h"
#include "../engines/fcitx5-rime/src/rimeengine.h"
#include "../engines/fcitx5-hallelujah/src/factory.h"
#include "../engines/fcitx5-rime/src/rimefactory.h"
#include "../fcitx5/src/modules/spell/spell.h"
#include "../iosfrontend/iosfrontend.h"
#include "../iosnotifications/iosnotifications.h"
Expand Down
2 changes: 1 addition & 1 deletion engines/fcitx5-hallelujah
2 changes: 1 addition & 1 deletion engines/fcitx5-rime
62 changes: 5 additions & 57 deletions patches/fcitx5.patch
Original file line number Diff line number Diff line change
@@ -1,16 +1,8 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index aa90bad4..b721b612 100644
index aa90bad4..fa6e165f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -81,7 +81,6 @@ endif()
if(${CMAKE_SYSTEM_NAME} MATCHES "BSD|DragonFly")
find_package(LibKVM REQUIRED)
endif()
-find_package(DL REQUIRED)

if (NOT TARGET LibIntl::LibIntl)
find_package(LibIntl REQUIRED)
@@ -191,9 +190,7 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in ${CMAKE_CURRENT_BINARY_DI
@@ -191,9 +191,7 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in ${CMAKE_CURRENT_BINARY_DI
include_directories(${CMAKE_CURRENT_BINARY_DIR})

add_subdirectory(src)
Expand Down Expand Up @@ -38,10 +30,10 @@ index 85c9865b..edf51a44 100644
)
target_include_directories(Fcitx5Config PUBLIC
diff --git a/src/lib/fcitx-utils/CMakeLists.txt b/src/lib/fcitx-utils/CMakeLists.txt
index e1498a14..4dfbe2e1 100644
index e1498a14..119d193d 100644
--- a/src/lib/fcitx-utils/CMakeLists.txt
+++ b/src/lib/fcitx-utils/CMakeLists.txt
@@ -121,23 +121,22 @@ ecm_setup_version(PROJECT
@@ -121,10 +121,9 @@ ecm_setup_version(PROJECT
PACKAGE_VERSION_FILE "${CMAKE_CURRENT_BINARY_DIR}/Fcitx5UtilsConfigVersion.cmake"
SOVERSION 2)

Expand All @@ -54,21 +46,6 @@ index e1498a14..4dfbe2e1 100644
EXPORT_NAME Utils
)
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 ${FMT_TARGET})
+target_link_libraries(Fcitx5Utils PRIVATE LibIntl::LibIntl Pthread::Pthread ${FMT_TARGET})
if(LIBKVM_FOUND)
target_link_libraries(Fcitx5Utils PRIVATE LibKVM::LibKVM)
endif()

if (NOT TARGET Systemd::Systemd)
- target_link_libraries(Fcitx5Utils PRIVATE ${LIBUV_TARGET})
+ target_link_libraries(Fcitx5Utils PUBLIC ${LIBUV_TARGET})
if (ENABLE_DBUS)
target_link_libraries(Fcitx5Utils PRIVATE PkgConfig::DBus)
endif()
diff --git a/src/lib/fcitx/CMakeLists.txt b/src/lib/fcitx/CMakeLists.txt
index df15dd57..3c1d3ff2 100644
--- a/src/lib/fcitx/CMakeLists.txt
Expand Down Expand Up @@ -112,20 +89,8 @@ index 55269f33..5e7b8d27 100644
if (registry) {
registerLoader(std::make_unique<StaticLibraryLoader>(registry));
}
diff --git a/src/lib/fcitx/instance.cpp b/src/lib/fcitx/instance.cpp
index d2e9aa23..72f82213 100644
--- a/src/lib/fcitx/instance.cpp
+++ b/src/lib/fcitx/instance.cpp
@@ -1921,7 +1921,6 @@ std::string Instance::addonForInputMethod(const std::string &imName) {
}

void Instance::configure() {
- startProcess({StandardPath::fcitxPath("bindir", "fcitx5-configtool")});
}

void Instance::configureAddon(const std::string &) {}
diff --git a/src/modules/spell/CMakeLists.txt b/src/modules/spell/CMakeLists.txt
index ab1ce4df..106a010c 100644
index ab1ce4df..e450d690 100644
--- a/src/modules/spell/CMakeLists.txt
+++ b/src/modules/spell/CMakeLists.txt
@@ -5,7 +5,7 @@ if (TARGET PkgConfig::Enchant)
Expand All @@ -137,20 +102,3 @@ index ab1ce4df..106a010c 100644
target_link_libraries(spell Fcitx5::Core)
if (TARGET PkgConfig::Enchant)
target_link_libraries(spell PkgConfig::Enchant)
@@ -17,6 +17,16 @@ install(FILES "${CMAKE_CURRENT_BINARY_DIR}/spell.conf" DESTINATION "${FCITX_INST
COMPONENT config)
fcitx5_export_module(Spell TARGET spell BUILD_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}" HEADERS spell_public.h INSTALL)

+add_custom_command(
+ TARGET spell
+ POST_BUILD COMMAND /bin/sh -c
+ \"
+ ${CMAKE_COMMAND} -E copy
+ ${CMAKE_CURRENT_BINARY_DIR}/spell.conf
+ ${CMAKE_BINARY_DIR}/keyboard/$<CONFIG>${CMAKE_XCODE_EFFECTIVE_PLATFORMS}/keyboard.appex/share/fcitx5/addon/spell.conf
+ \"
+)
+
if (BUILD_SPELL_DICT)
set(DICT_COMP_SRC
comp_spell_dict.cpp
18 changes: 3 additions & 15 deletions patches/hallelujah.patch
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,12 @@ index 7ffcf34..a57a061 100644
add_subdirectory(src)
if (ENABLE_TEST)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index dcbd627..05832b4 100644
index bf6da01..e117fa5 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1,4 +1,4 @@
-add_library(hallelujah MODULE hallelujah.cpp)
+add_library(hallelujah STATIC hallelujah.cpp)
-add_library(hallelujah MODULE hallelujah.cpp factory.cpp)
+add_library(hallelujah STATIC hallelujah.cpp factory.cpp)
target_link_libraries(hallelujah Fcitx5::Core Fcitx5::Module::Spell fmt::fmt ${MARISA_TARGET} ${JSONC_TARGET})
install(TARGETS hallelujah DESTINATION "${FCITX_INSTALL_LIBDIR}/fcitx5")
fcitx5_translate_desktop_file(hallelujah.conf.in hallelujah.conf)
diff --git a/src/hallelujah.h b/src/hallelujah.h
index 2dcee57..caf1bec 100644
--- a/src/hallelujah.h
+++ b/src/hallelujah.h
@@ -98,7 +98,6 @@ private:
class HallelujahFactory : public AddonFactory {
public:
AddonInstance *create(AddonManager *manager) override {
- registerDomain("fcitx5-hallelujah", FCITX_INSTALL_LOCALEDIR);
return new HallelujahEngine(manager->instance());
}
};
30 changes: 15 additions & 15 deletions patches/rime.patch
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ index 1a1637a..92a41e0 100644
add_subdirectory(po)
add_subdirectory(src)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 0854a9a..a3ef4a0 100644
index 78ef79b..c4abccd 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -22,7 +22,9 @@ else()
@@ -23,7 +23,9 @@ else()
add_definitions(-DFCITX_RIME_NO_DBUS)
endif()

Expand All @@ -36,7 +36,7 @@ index 0854a9a..a3ef4a0 100644
install(TARGETS rime DESTINATION "${CMAKE_INSTALL_LIBDIR}/fcitx5")
fcitx5_translate_desktop_file(rime.conf.in rime.conf)
diff --git a/src/rimeengine.cpp b/src/rimeengine.cpp
index 090ee37..e924ba7 100644
index 49fc5b8..b3212fa 100644
--- a/src/rimeengine.cpp
+++ b/src/rimeengine.cpp
@@ -47,6 +47,8 @@
Expand Down Expand Up @@ -119,15 +119,15 @@ index 090ee37..e924ba7 100644
blockMessage = true;
}
} else if (messageType == "option") {
diff --git a/src/rimeengine.h b/src/rimeengine.h
index 6bec003..10940c8 100644
--- a/src/rimeengine.h
+++ b/src/rimeengine.h
@@ -238,7 +238,6 @@ private:
class RimeEngineFactory : public AddonFactory {
public:
AddonInstance *create(AddonManager *manager) override {
- registerDomain("fcitx5-rime", FCITX_INSTALL_LOCALEDIR);
return new RimeEngine(manager->instance());
}
};
diff --git a/src/rimefactory.cpp b/src/rimefactory.cpp
index 91a2f37..b061d11 100644
--- a/src/rimefactory.cpp
+++ b/src/rimefactory.cpp
@@ -11,7 +11,6 @@
namespace fcitx {

AddonInstance *RimeEngineFactory::create(AddonManager *manager) {
- registerDomain("fcitx5-rime", FCITX_INSTALL_LOCALEDIR);
return new RimeEngine(manager->instance());
}

4 changes: 0 additions & 4 deletions scripts/install-deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@ for dep in "${deps[@]}"; do
tar xjvf cache/$file -C $EXTRACT_DIR
done

sed -i '' "s|=/usr/include|=$(pwd)/$EXTRACT_DIR/include|" $EXTRACT_DIR/lib/pkgconfig/{json-c,libuv,marisa,rime}.pc
sed -i '' "s|-L\${libdir} -luv|$(pwd)/$EXTRACT_DIR/lib/libuv.a|" $EXTRACT_DIR/lib/pkgconfig/libuv.pc
sed -E -i '' "s|Libs:.*-l(.*)|Libs: $(pwd)/$EXTRACT_DIR/lib/lib\1.a|" $EXTRACT_DIR/lib/pkgconfig/json-c.pc

plugins=(
rime
)
Expand Down
20 changes: 13 additions & 7 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,25 +46,31 @@ set_target_properties(${BUNDLE_NAME} PROPERTIES

set_xcode_property(${BUNDLE_NAME} CODE_SIGN_ENTITLEMENTS ${PROJECT_SOURCE_DIR}/assets/app.entitlements)

set(ADDON_PREFIX "share/fcitx5/addon")
set(IM_PREFIX "share/fcitx5/inputmethod")

copy_to_keyboard(copy "${PROJECT_BINARY_DIR}/profile" profile)
copy_to_keyboard(copy "${PROJECT_BINARY_DIR}/iosfrontend/iosfrontend.conf" "share/fcitx5/addon/iosfrontend.conf")
copy_to_keyboard(copy "${PROJECT_BINARY_DIR}/iosnotifications/notifications.conf" "share/fcitx5/addon/notifications.conf")
copy_to_keyboard(copy "${PROJECT_BINARY_DIR}/uipanel/uipanel.conf" "share/fcitx5/addon/uipanel.conf")
copy_to_keyboard(copy "${PROJECT_BINARY_DIR}/iosfrontend/iosfrontend.conf" "${ADDON_PREFIX}/iosfrontend.conf")
copy_to_keyboard(copy "${PROJECT_BINARY_DIR}/iosnotifications/notifications.conf" "${ADDON_PREFIX}/notifications.conf")
copy_to_keyboard(copy "${PROJECT_BINARY_DIR}/uipanel/uipanel.conf" "${ADDON_PREFIX}/uipanel.conf")

set(FCITX5_MODULE_BINARY_DIR "${PROJECT_BINARY_DIR}/fcitx5/src/modules")
copy_to_keyboard(copy "${FCITX5_MODULE_BINARY_DIR}/spell/spell.conf" "${ADDON_PREFIX}/spell.conf")

if (HALLELUJAH)
set(HALLELUJAH_SOURCE_DIR "${PROJECT_SOURCE_DIR}/engines/fcitx5-hallelujah")
set(HALLELUJAH_BINARY_DIR "${PROJECT_BINARY_DIR}/engines/fcitx5-hallelujah")
copy_to_keyboard(copy "${HALLELUJAH_BINARY_DIR}/data/google_227800_words.bin" "share/hallelujah/google_227800_words.bin")
copy_to_keyboard(copy "${HALLELUJAH_SOURCE_DIR}/data/words.json" "share/hallelujah/words.json")
copy_to_keyboard(copy "${HALLELUJAH_SOURCE_DIR}/data/cedict.json" "share/hallelujah/cedict.json")
copy_to_keyboard(copy "${HALLELUJAH_BINARY_DIR}/src/hallelujah-addon.conf" "share/fcitx5/addon/hallelujah.conf")
copy_to_keyboard(copy "${HALLELUJAH_BINARY_DIR}/src/hallelujah.conf" "share/fcitx5/inputmethod/hallelujah.conf")
copy_to_keyboard(copy "${HALLELUJAH_BINARY_DIR}/src/hallelujah-addon.conf" "${ADDON_PREFIX}/hallelujah.conf")
copy_to_keyboard(copy "${HALLELUJAH_BINARY_DIR}/src/hallelujah.conf" "${IM_PREFIX}/hallelujah.conf")
endif()

if (RIME)
set(RIME_BINARY_DIR "${PROJECT_BINARY_DIR}/engines/fcitx5-rime")
copy_to_keyboard(copy "${RIME_BINARY_DIR}/src/rime-addon.conf" "share/fcitx5/addon/rime.conf")
copy_to_keyboard(copy "${RIME_BINARY_DIR}/src/rime.conf" "share/fcitx5/inputmethod/rime.conf")
copy_to_keyboard(copy "${RIME_BINARY_DIR}/src/rime-addon.conf" "${ADDON_PREFIX}/rime.conf")
copy_to_keyboard(copy "${RIME_BINARY_DIR}/src/rime.conf" "${IM_PREFIX}/rime.conf")
copy_to_keyboard(copy_directory "${PREBUILDER_SHARE_DIR}/rime-data" "share/rime-data")
endif()

Expand Down

0 comments on commit b91e300

Please sign in to comment.