Skip to content

Commit

Permalink
build(jni): try to improve the build of rime and its plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
WhiredPlanck committed Nov 16, 2023
1 parent 1f35a8e commit f9d3cfc
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 55 deletions.
5 changes: 1 addition & 4 deletions app/src/main/jni/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
15 changes: 2 additions & 13 deletions app/src/main/jni/cmake/FindBoost.cmake
Original file line number Diff line number Diff line change
@@ -1,20 +1,9 @@
set(Boost_FOUND TRUE)

list(TRANSFORM ${BOOST_INCLUDE_LIBRARIES}
PREPEND Boost::
list(TRANSFORM BOOST_INCLUDE_LIBRARIES
PREPEND "Boost::"
OUTPUT_VARIABLE Boost_LIBRARIES
)

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)
40 changes: 40 additions & 0 deletions app/src/main/jni/cmake/Rime.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# 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
)

# librime-lua
file(REMOVE "${CMAKE_SOURCE_DIR}/librime/plugins/librime-lua/thirdparty")
file(CREATE_LINK
"${CMAKE_SOURCE_DIR}/librime-lua-deps"
"${CMAKE_SOURCE_DIR}/librime-lua/thirdparty/librime-lua-deps"
SYMBOLIC COPY_ON_ERROR
)

# symlink plugins
foreach(plugin ${RIME_PLUGINS})
file(CREATE_LINK
"${CMAKE_SOURCE_DIR}/${plugin}"
"${CMAKE_SOURCE_DIR}/librime/plugins/${plugin}"
SYMBOLIC COPY_ON_ERROR
)
endforeach()

# 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
)
38 changes: 0 additions & 38 deletions app/src/main/jni/cmake/RimePlugins.cmake

This file was deleted.

0 comments on commit f9d3cfc

Please sign in to comment.