From 5591986539475ca57987c5b780f22e05d5d94858 Mon Sep 17 00:00:00 2001 From: WhiredPlanck Date: Thu, 16 Nov 2023 20:18:39 +0800 Subject: [PATCH] build(jni): try to improve the build of rime and its plugins --- app/src/main/jni/CMakeLists.txt | 5 +--- app/src/main/jni/cmake/FindBoost.cmake | 11 ------- app/src/main/jni/cmake/Rime.cmake | 38 ++++++++++++++++++++++++ app/src/main/jni/cmake/RimePlugins.cmake | 38 ------------------------ 4 files changed, 39 insertions(+), 53 deletions(-) create mode 100644 app/src/main/jni/cmake/Rime.cmake delete mode 100644 app/src/main/jni/cmake/RimePlugins.cmake diff --git a/app/src/main/jni/CMakeLists.txt b/app/src/main/jni/CMakeLists.txt index 1843035ff6..157f99410f 100644 --- a/app/src/main/jni/CMakeLists.txt +++ b/app/src/main/jni/CMakeLists.txt @@ -47,12 +47,9 @@ option(USE_SYSTEM_MARISA "" ON) add_subdirectory(OpenCC) include(OpenccWorkarounds) -include(RimePlugins) - set(X11Keysym "${CMAKE_SOURCE_DIR}/librime/include") include_directories("${X11Keysym}") -option(BUILD_TEST "" OFF) -add_subdirectory(librime) +include(Rime) add_subdirectory(librime_jni) diff --git a/app/src/main/jni/cmake/FindBoost.cmake b/app/src/main/jni/cmake/FindBoost.cmake index 7b8c96f678..a5799c59f7 100644 --- a/app/src/main/jni/cmake/FindBoost.cmake +++ b/app/src/main/jni/cmake/FindBoost.cmake @@ -4,16 +4,5 @@ foreach(_lib ${BOOST_INCLUDE_LIBRARIES}) list(APPEND Boost_LIBRARIES Boost::${_lib}) endforeach() -if(NOT TARGET Boost::boost) - add_library(Boost::boost INTERFACE IMPORTED) - foreach(lib ${Boost_LIBRARIES}) - get_target_property(_include ${lib} INTERFACE_INCLUDE_DIRECTORIES) - list(APPEND includes ${_include}) - endforeach() - set_target_properties(Boost::boost PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${includes}" - ) -endif() - # for librime-charcode set(Boost_LOCALE_LIBRARIES Boost::locale) diff --git a/app/src/main/jni/cmake/Rime.cmake b/app/src/main/jni/cmake/Rime.cmake new file mode 100644 index 0000000000..db3b68db99 --- /dev/null +++ b/app/src/main/jni/cmake/Rime.cmake @@ -0,0 +1,38 @@ +# if you want to add some new plugins, add them to librime_jni/rime_jni.cc too +set(RIME_PLUGINS + librime-lua + librime-charcode + librime-octagram + librime-predict +) + +# symlink plugins +foreach(plugin ${RIME_PLUGINS}) + execute_process(COMMAND ln -sv + "${CMAKE_SOURCE_DIR}/${plugin}" + "${CMAKE_SOURCE_DIR}/librime/plugins" + ) +endforeach() + +# librime-lua +file(REMOVE "${CMAKE_SOURCE_DIR}/librime/plugins/librime-lua/thirdparty") +execute_process(COMMAND ln -sv + "${CMAKE_SOURCE_DIR}/librime-lua-deps" + "${CMAKE_SOURCE_DIR}/librime/plugins/librime-lua/thirdparty" +) + +# librime-charcode +option(BUILD_WITH_ICU "" OFF) + +option(BUILD_TEST "" OFF) +option(BUILD_STATIC "" ON) +add_subdirectory(librime) + +target_link_libraries(rime-charcode-objs + Boost::asio + Boost::locale +) + +target_link_libraries(rime-lua-objs + Boost::optional +) diff --git a/app/src/main/jni/cmake/RimePlugins.cmake b/app/src/main/jni/cmake/RimePlugins.cmake deleted file mode 100644 index 8d371755ab..0000000000 --- a/app/src/main/jni/cmake/RimePlugins.cmake +++ /dev/null @@ -1,38 +0,0 @@ -# if you want to add some new plugins, add them to librime_jni/rime_jni.cc too -set(RIME_PLUGINS - librime-lua - librime-charcode - librime-octagram - librime-predict -) - -# plugins didn't use target_link_libraries, the usage-requirements won't work, include manually -find_package(Boost) -get_target_property(PLUGIN_INCLUDES Boost::boost - INTERFACE_INCLUDE_DIRECTORIES -) -include_directories(${PLUGIN_INCLUDES}) - -# move plugins -file(GLOB old_plugin_files "librime/plugins/*") -foreach(file ${old_plugin_files}) - if(IS_DIRECTORY ${file}) # plugin is directory - file(REMOVE "${file}") - endif() -endforeach() -foreach(plugin ${RIME_PLUGINS}) - execute_process(COMMAND ln -s - "${CMAKE_SOURCE_DIR}/${plugin}" - "${CMAKE_SOURCE_DIR}/librime/plugins" - ) -endforeach() - -# librime-lua -file(REMOVE "${CMAKE_SOURCE_DIR}/librime/plugins/librime-lua/thirdparty") -execute_process(COMMAND ln -s - "${CMAKE_SOURCE_DIR}/librime-lua-deps" - "${CMAKE_SOURCE_DIR}/librime/plugins/librime-lua/thirdparty" -) - -# librime-charcode -option(BUILD_WITH_ICU "" OFF)