-
-
Save bczhc/cd271734f812f32b4c9c70c766f1c95f to your computer and use it in GitHub Desktop.
Revisions
-
bczhc revised this gist
Jul 30, 2025 . 1 changed file with 11 additions and 11 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,39 +2,39 @@ ```bash git clone https://github.com/osfans/trime --recursive cd trime git checkout 436c8fc42af638fdd8744533beec03567ec03c6c ``` ## Apply patch ```diff diff --git a/app/src/main/jni/librime_jni/rime_jni.cc b/app/src/main/jni/librime_jni/rime_jni.cc index 01c10d02..0416914d 100644 --- a/app/src/main/jni/librime_jni/rime_jni.cc +++ b/app/src/main/jni/librime_jni/rime_jni.cc @@ -17,7 +17,7 @@ extern void rime_require_module_charcode(); extern void rime_require_module_octagram(); extern void rime_require_module_predict(); // librime is compiled as a static library, we have to link modules explicitly -static void declare_librime_module_dependencies() { +extern "C" void declare_librime_module_dependencies() { rime_require_module_lua(); rime_require_module_charcode(); rime_require_module_octagram(); @@ -173,12 +173,6 @@ static inline bool is_rime_running() { return Rime::Instance().isRunning(); } GlobalRefSingleton *GlobalRef; -JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *jvm, void *reserved) { - GlobalRef = new GlobalRefSingleton(jvm); - declare_librime_module_dependencies(); - return JNI_VERSION_1_6; -} - extern "C" JNIEXPORT void JNICALL Java_com_osfans_trime_core_Rime_startupRime( JNIEnv *env, jclass clazz, jstring shared_dir, jstring user_dir, jboolean full_check) { ``` ## Build -
bczhc revised this gist
Sep 4, 2024 . 1 changed file with 3 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -94,3 +94,6 @@ libs 5 directories, 4 files ``` ## See also - https://github.com/bczhc/rime-android -
bczhc revised this gist
May 23, 2023 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,7 @@ ## Clone Trime ```bash git clone https://github.com/osfans/trime --recursive ``` ## Apply patch -
bczhc revised this gist
May 4, 2023 . 1 changed file with 10 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -8,9 +8,18 @@ git clone https://github.com/osfans/trime ```diff diff --git a/app/src/main/jni/librime_jni/rime_jni.cc b/app/src/main/jni/librime_jni/rime_jni.cc index 0dfd132b..419d3a07 100644 --- a/app/src/main/jni/librime_jni/rime_jni.cc +++ b/app/src/main/jni/librime_jni/rime_jni.cc @@ -11,7 +11,7 @@ extern void rime_require_module_lua(); extern void rime_require_module_charcode(); extern void rime_require_module_octagram(); // librime is compiled as a static library, we have to link modules explicitly -static void declare_librime_module_dependencies() { +extern "C" void declare_librime_module_dependencies() { rime_require_module_lua(); rime_require_module_charcode(); rime_require_module_octagram(); @@ -132,11 +132,11 @@ static inline bool is_rime_running() { return Rime::Instance().isRunning(); } GlobalRefSingleton *GlobalRef; -
bczhc created this gist
May 3, 2023 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,87 @@ ## Clone Trime ```bash git clone https://github.com/osfans/trime ``` ## Apply patch ```diff diff --git a/app/src/main/jni/librime_jni/rime_jni.cc b/app/src/main/jni/librime_jni/rime_jni.cc index 0dfd132b..88e7edd6 100644 --- a/app/src/main/jni/librime_jni/rime_jni.cc +++ b/app/src/main/jni/librime_jni/rime_jni.cc @@ -132,11 +132,11 @@ static inline bool is_rime_running() { return Rime::Instance().isRunning(); } GlobalRefSingleton *GlobalRef; -JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *jvm, void *reserved) { +/*JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *jvm, void *reserved) { GlobalRef = new GlobalRefSingleton(jvm); declare_librime_module_dependencies(); return JNI_VERSION_1_6; -} +}*/ extern "C" JNIEXPORT void JNICALL Java_com_osfans_trime_core_Rime_startupRime( JNIEnv *env, jclass clazz, jstring shared_dir, jstring user_dir, ``` ## Build Save this script as `app/src/main/jni/build`: ```ruby #!/bin/env ruby `rm -rf libs; mkdir libs` ndk_dir = ENV['ANDROID_HOME'] + '/ndk-ln' targets = 'arm64-v8a-29,x86-29,armeabi-v7a-21,x86_64-29' targets.split(',').each do |group| `rm -rf target; mkdir target` Dir.chdir 'target' scan = group.scan(/^(.*)-([0-9]+)$/) abi = scan[0][0] api = scan[0][1] puts [abi, api].inspect lib_copy_dir = "../libs/#{abi}" Dir.mkdir lib_copy_dir system "cmake \ -DCMAKE_TOOLCHAIN_FILE=#{ndk_dir}/build/cmake/android.toolchain.cmake \ -DANDROID_ABI=#{abi} \ -DANDROID_PLATFORM=android-#{api} -G Ninja .." system 'ninja' `cp -v 'librime_jni/librime_jni.so' #{lib_copy_dir}/librime.so` Dir.chdir '..' end ``` Then check and replace `ndk_dir` variable, and run it: ```bash cd /app/src/main/jni ./build ``` ## Artifacts: ```console ~/open-source/trime/app/src/main/jni develop ⇡2 !1 ?4 ❯ tree libs 11:23:51 libs ├── arm64-v8a │ └── librime.so ├── armeabi-v7a │ └── librime.so ├── x86 │ └── librime.so └── x86_64 └── librime.so 5 directories, 4 files ```