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
4 changes: 4 additions & 0 deletions .github/workflows/commit-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,7 @@ jobs:
path: app/build/intermediates/merged_native_libs/debug/mergeDebugNativeLibs/out/lib/*
# keep 90 days
retention-days: 90

- name: Stop Gradle daemon
if: always()
run: ./gradlew --stop
4 changes: 4 additions & 0 deletions .github/workflows/pull-request-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,7 @@ jobs:
path: app/build/outputs/apk/debug/
# keep 30 days
retention-days: 30

- name: Stop Gradle daemon
if: always()
run: ./gradlew --stop
64 changes: 35 additions & 29 deletions app/src/main/jni/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,58 +2,64 @@
#
# SPDX-License-Identifier: GPL-3.0-or-later

cmake_minimum_required(VERSION 3.18.0)
cmake_minimum_required(VERSION 4.1)

project(trime VERSION 3.0.0)

# for reproducible build; GNU hash is enough above API 22
add_link_options("LINKER:--build-id=none")
list(PREPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")

set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
# strip absolute source paths from debug info for reproducible builds
add_library(trime-reproducible-build INTERFACE IMPORTED)
set_target_properties(
trime-reproducible-build
PROPERTIES INTERFACE_COMPILE_OPTIONS
"-ffile-prefix-map=${CMAKE_CURRENT_SOURCE_DIR}=.")

# general options
option(BUILD_SHARED_LIBS "" OFF)
option(BUILD_TESTING "" OFF)
option(BUILD_SHARED_LIBS "Build shared libraries" OFF)
option(BUILD_TESTING "Build tests" OFF)
option(ENABLE_LOGGING "Enable logging with spdlog library" ON)

include(Boost)

# spdlog is owned by librime and is linked statically into rime-static.
if(ENABLE_LOGGING)
set(SPDLOG_BUILD_SHARED OFF CACHE BOOL "" FORCE)
set(SPDLOG_BUILD_PIC ON CACHE BOOL "" FORCE)
set(SPDLOG_BUILD_EXAMPLE OFF CACHE BOOL "" FORCE)
set(SPDLOG_BUILD_TESTS OFF CACHE BOOL "" FORCE)
set(SPDLOG_INSTALL OFF CACHE BOOL "" FORCE)
set(SPDLOG_FMT_EXTERNAL OFF CACHE BOOL "" FORCE)
set(SPDLOG_BUILD_SHARED OFF)
set(SPDLOG_BUILD_PIC ON)
set(SPDLOG_BUILD_EXAMPLE OFF)
set(SPDLOG_BUILD_TESTS OFF)
set(SPDLOG_INSTALL OFF)
set(SPDLOG_FMT_EXTERNAL OFF)
add_subdirectory(librime/deps/spdlog EXCLUDE_FROM_ALL)
target_compile_options(
spdlog PRIVATE "-ffile-prefix-map=${CMAKE_CURRENT_SOURCE_DIR}=.")
target_link_libraries(spdlog PRIVATE trime-reproducible-build)
endif()

option(YAML_CPP_BUILD_TOOLS "" OFF)
option(YAML_CPP_BUILD_TESTS "" OFF)
option(YAML_CPP_INSTALL "" OFF)
# yaml-cpp
option(YAML_CPP_BUILD_TOOLS "Build yaml-cpp tools" OFF)
option(YAML_CPP_BUILD_TESTS "Build yaml-cpp tests" OFF)
option(YAML_CPP_INSTALL "Install yaml-cpp" OFF)
add_subdirectory(librime/deps/yaml-cpp)

# enable compress for leveldb
option(SNAPPY_BUILD_TESTS "" OFF)
option(SNAPPY_BUILD_BENCHMARKS "" OFF)
option(SNAPPY_INSTALL "" OFF)
# snappy: compression for leveldb
option(SNAPPY_BUILD_TESTS "Build snappy tests" OFF)
option(SNAPPY_BUILD_BENCHMARKS "Build snappy benchmarks" OFF)
option(SNAPPY_INSTALL "Install snappy" OFF)
add_subdirectory(snappy)

# leveldb
set(HAVE_SNAPPY TRUE)
option(LEVELDB_BUILD_TESTS "" OFF)
option(LEVELDB_BUILD_BENCHMARKS "" OFF)
option(LEVELDB_INSTALL "" OFF)
option(LEVELDB_BUILD_TESTS "Build leveldb tests" OFF)
option(LEVELDB_BUILD_BENCHMARKS "Build leveldb benchmarks" OFF)
option(LEVELDB_INSTALL "Install leveldb" OFF)
add_subdirectory(librime/deps/leveldb)

# marisa
add_subdirectory(librime/deps/marisa-trie)
target_compile_options(
marisa PRIVATE "-ffile-prefix-map=${CMAKE_CURRENT_SOURCE_DIR}=.")

set(LIBMARISA marisa)
option(USE_SYSTEM_MARISA "" ON)
option(USE_SYSTEM_MARISA "Use the system marisa library" ON)
target_link_libraries(marisa PRIVATE trime-reproducible-build)

# opencc
add_subdirectory(librime/deps/opencc)
# OpenCC's data/ builds its dictionaries by running the freshly built
# opencc_dict, which is an Android executable and cannot run on the build
Expand All @@ -64,8 +70,8 @@ set_property(
PROPERTY EXCLUDE_FROM_ALL TRUE)
include(OpenccWorkarounds)

# keysym.h is shipped in librime/include for cross-compilation.
set(X11Keysym "${CMAKE_SOURCE_DIR}/librime/include")
include_directories("${X11Keysym}")

include(Rime)

Expand Down
9 changes: 6 additions & 3 deletions app/src/main/jni/cmake/FindBoost.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,21 @@
#
# SPDX-License-Identifier: GPL-3.0-or-later

# Boost is provided by the downloaded CMake distribution in the build tree.
set(Boost_FOUND TRUE)
set(Boost_VERSION ${BOOST_VERSION})

# Export the Boost components as the namespaced targets librime expects.
list(TRANSFORM BOOST_INCLUDE_LIBRARIES PREPEND Boost:: OUTPUT_VARIABLE
Boost_LIBRARIES)

# include directories
file(
GLOB __boost_installed_libs
LIST_DIRECTORIES true
RELATIVE "${CMAKE_BINARY_DIR}"
"${CMAKE_BINARY_DIR}/boost/libs/*")

foreach(__lib ${__boost_installed_libs})
set(__full_dir "${CMAKE_SOURCE_DIR}/${__lib}/include")
list(APPEND Boost_INCLUDE_DIRS "${__full_dir}")
foreach(__lib IN LISTS __boost_installed_libs)
list(APPEND Boost_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/${__lib}/include")
endforeach()
4 changes: 3 additions & 1 deletion app/src/main/jni/cmake/FindLevelDb.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@
#
# SPDX-License-Identifier: GPL-3.0-or-later

set(LevelDb_FOUNT TRUE)
# leveldb is added as a subdirectory of the top-level build.
set(LevelDb_FOUND TRUE)
set(LevelDb_LIBRARY leveldb)
set(LevelDb_INCLUDE_PATH "${CMAKE_SOURCE_DIR}/librime/deps/leveldb/include")
7 changes: 4 additions & 3 deletions app/src/main/jni/cmake/OpenccWorkarounds.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
#
# SPDX-License-Identifier: GPL-3.0-or-later

# Since OpenCC doesn't include its headers in the binary dir, we need to install
# them manually.
file(GLOB LIBOPENCC_HEADERS librime/deps/opencc/src/*.hpp)
# OpenCC doesn't put its headers in the binary dir, so copy them manually.
file(
GLOB LIBOPENCC_HEADERS CONFIGURE_DEPENDS
"${CMAKE_SOURCE_DIR}/librime/deps/opencc/src/*.hpp")
file(COPY ${LIBOPENCC_HEADERS} DESTINATION "${CMAKE_BINARY_DIR}/include/opencc")
18 changes: 8 additions & 10 deletions app/src/main/jni/cmake/Rime.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,19 @@ foreach(plugin ${RIME_PLUGINS})
endif()
endforeach()

# librime-lua
# librime-lua depends on the thirdparty sources in a separate submodule.
if(NOT EXISTS "${CMAKE_SOURCE_DIR}/librime/plugins/librime-lua/thirdparty")
file(CREATE_LINK "${CMAKE_SOURCE_DIR}/librime-lua-deps"
"${CMAKE_SOURCE_DIR}/librime/plugins/librime-lua/thirdparty"
COPY_ON_ERROR SYMBOLIC)
endif()

option(BUILD_TEST "" OFF)
option(BUILD_STATIC "" ON)
# librime
option(BUILD_TEST "Build librime tests" OFF)
option(BUILD_STATIC "Build librime statically" ON)
add_subdirectory(librime)
target_compile_options(
rime-static PRIVATE "-ffile-prefix-map=${CMAKE_CURRENT_SOURCE_DIR}=." "-Wno-error=deprecated-declarations")

target_compile_options(
rime-lua-objs PRIVATE "-ffile-prefix-map=${CMAKE_CURRENT_SOURCE_DIR}=.")

target_compile_options(
rime-octagram-objs PRIVATE "-ffile-prefix-map=${CMAKE_CURRENT_SOURCE_DIR}=.")
rime-static PRIVATE "-Wno-error=deprecated-declarations")
target_link_libraries(rime-static PRIVATE trime-reproducible-build)
target_link_libraries(rime-lua-objs PRIVATE trime-reproducible-build)
target_link_libraries(rime-octagram-objs PRIVATE trime-reproducible-build)
2 changes: 1 addition & 1 deletion app/src/main/jni/librime
Submodule librime updated 85 files
+6 −10 .github/workflows/windows-build.yml
+122 −0 CHANGELOG.md
+11 −6 CMakeLists.txt
+1 −1 README-windows.md
+3 −1 README.md
+6 −0 data/test/compact_dictionary_pack_test.dict.yaml
+9 −0 data/test/compact_dictionary_test.dict.yaml
+1 −1 include/darts.h
+1 −1 src/CMakeLists.txt
+16 −0 src/rime/algo/encoder.cc
+11 −1 src/rime/algo/encoder.h
+2 −1 src/rime/candidate.cc
+1 −1 src/rime/candidate.h
+2 −2 src/rime/config/auto_patch_config_plugin.cc
+1 −2 src/rime/config/build_info_plugin.cc
+1 −1 src/rime/config/config_compiler.cc
+2 −2 src/rime/config/default_config_plugin.cc
+4 −6 src/rime/config/legacy_dictionary_config_plugin.cc
+2 −3 src/rime/config/legacy_preset_config_plugin.cc
+3 −3 src/rime/config/save_output_plugin.cc
+39 −0 src/rime/dict/compact_entries.h
+2 −2 src/rime/dict/corrector.cc
+217 −43 src/rime/dict/dict_compiler.cc
+2 −1 src/rime/dict/dict_compiler.h
+1 −1 src/rime/dict/dictionary.cc
+120 −48 src/rime/dict/entry_collector.cc
+37 −2 src/rime/dict/entry_collector.h
+3 −3 src/rime/dict/preset_vocabulary.cc
+110 −68 src/rime/dict/reverse_lookup_dictionary.cc
+13 −2 src/rime/dict/reverse_lookup_dictionary.h
+102 −20 src/rime/dict/table.cc
+22 −2 src/rime/dict/table.h
+2 −2 src/rime/dict/user_db.cc
+1 −1 src/rime/dict/user_dictionary.cc
+7 −5 src/rime/dict/vocabulary.h
+4 −4 src/rime/engine.h
+1 −1 src/rime/filter.h
+1 −1 src/rime/gear/ascii_composer.cc
+1 −1 src/rime/gear/charset_filter.cc
+1 −1 src/rime/gear/chord_composer.cc
+1 −1 src/rime/gear/editor.cc
+1 −1 src/rime/gear/fallback_segmentor.cc
+1 −1 src/rime/gear/memory.cc
+1 −1 src/rime/gear/navigator.cc
+16 −13 src/rime/gear/poet.cc
+3 −3 src/rime/gear/punctuator.cc
+1 −1 src/rime/gear/reverse_lookup_filter.cc
+1 −1 src/rime/gear/reverse_lookup_translator.cc
+1 −2 src/rime/gear/schema_list_translator.cc
+24 −25 src/rime/gear/script_translator.cc
+1 −2 src/rime/gear/simplifier.cc
+1 −1 src/rime/gear/single_char_filter.cc
+1 −2 src/rime/gear/switch_translator.cc
+3 −3 src/rime/gear/table_translator.cc
+2 −8 src/rime/gear/translator_commons.h
+1 −2 src/rime/lever/deployment_tasks.cc
+9 −9 src/rime/lever/deployment_tasks.h
+1 −1 src/rime/lever/levers_api_impl.h
+1 −1 src/rime/lever/switcher_settings.cc
+1 −1 src/rime/menu.h
+1 −3 src/rime/processor.h
+1 −1 src/rime/segmentation.cc
+1 −0 src/rime/switcher.h
+1 −1 src/rime/switches.cc
+1 −2 src/rime/translation.cc
+2 −2 src/rime_api.cc
+8 −2 src/rime_api.h
+2 −2 src/rime_api_impl.cc
+1 −1 src/rime_api_stdbool.cc
+4 −0 src/rime_api_stdbool.h
+22 −0 test/candidate_test.cc
+54 −0 test/dictionary_test.cc
+76 −1 test/entry_collector_test.cc
+58 −0 test/poet_test.cc
+25 −0 test/reverse_lookup_delimiter_test.cc
+56 −0 test/table_test.cc
+4 −2 test/user_dictionary_test.cc
+4 −1 tools/CMakeLists.txt
+1 −1 tools/codepage.h
+249 −0 tools/completion_catalog.cc
+29 −0 tools/completion_catalog.h
+1,049 −162 tools/line_editor.cc
+76 −3 tools/line_editor.h
+134 −19 tools/rime_api_console.cc
+1 −1 tools/rime_table_decompiler.cc
9 changes: 7 additions & 2 deletions app/src/main/jni/librime_jni/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,16 @@

find_package(Opencc REQUIRED)

aux_source_directory(. RIME_JNI_SOURCES)
file(GLOB RIME_JNI_SOURCES CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/*.cc")
add_library(rime_jni SHARED ${RIME_JNI_SOURCES})
target_link_libraries(rime_jni rime-static ${Opencc_LIBRARY})

# for reproducible build; GNU hash is enough above API 22
target_link_libraries(rime_jni PRIVATE rime-static ${Opencc_LIBRARY})
target_link_options(rime_jni PRIVATE "LINKER:--build-id=none")

target_include_directories(rime_jni PRIVATE
"${CMAKE_BINARY_DIR}/librime/src"
"${CMAKE_SOURCE_DIR}/librime/src"
"${X11Keysym}"
"${Opencc_INCLUDE_PATH}"
)
17 changes: 14 additions & 3 deletions build-logic/convention/src/main/kotlin/OpenCCDataPlugin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import org.gradle.api.tasks.TaskProvider
import org.gradle.kotlin.dsl.create
import org.gradle.kotlin.dsl.register
import org.gradle.process.ExecOperations
import java.io.ByteArrayOutputStream
import java.io.File
import javax.inject.Inject

Expand Down Expand Up @@ -382,10 +383,20 @@ class OpenCCDataPlugin : Plugin<Project> {
cmake: String,
args: List<String>,
) {
execOperations
.exec {
val output = ByteArrayOutputStream()
val exitValue =
execOperations.exec {
commandLine = listOf(cmake) + args
}.assertNormalExitValue()
standardOutput = output
errorOutput = output
isIgnoreExitValue = true
}.exitValue
if (exitValue != 0) {
throw GradleException(
"OpenCC host build failed with exit code $exitValue:\n" +
output.toString(Charsets.UTF_8),
)
}
}
}
}
Loading