Skip to content

Commit 071297e

Browse files
committed
refactor: pass version name to rime setup via JNI
1 parent dbd5ed0 commit 071297e

File tree

3 files changed

+16
-16
lines changed

3 files changed

+16
-16
lines changed

app/src/main/java/com/osfans/trime/core/Rime.kt

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
package com.osfans.trime.core
66

7+
import com.osfans.trime.BuildConfig
78
import com.osfans.trime.data.base.DataManager
89
import com.osfans.trime.data.opencc.OpenCCDictManager
910
import com.osfans.trime.data.schema.SchemaManager
@@ -54,8 +55,15 @@ class Rime :
5455

5556
val sharedDataDir = DataManager.sharedDataDir.absolutePath
5657
val userDataDir = DataManager.userDataDir.absolutePath
57-
Timber.i("Starting up Rime APIs ...")
58-
startupRime(sharedDataDir, userDataDir, fullCheck)
58+
Timber.d(
59+
"""
60+
Starting rime with:
61+
sharedDataDir: $sharedDataDir
62+
userDataDir: $userDataDir
63+
fullCheck: $fullCheck
64+
""".trimIndent(),
65+
)
66+
startupRime(sharedDataDir, userDataDir, BuildConfig.BUILD_VERSION_NAME, fullCheck)
5967

6068
lifecycleImpl.emitState(RimeLifecycle.State.READY)
6169

@@ -298,6 +306,7 @@ class Rime :
298306
external fun startupRime(
299307
sharedDir: String,
300308
userDir: String,
309+
versionName: String,
301310
fullCheck: Boolean,
302311
)
303312

app/src/main/jni/librime_jni/CMakeLists.txt

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,3 @@ target_include_directories(rime_jni PRIVATE
1212
"${CMAKE_SOURCE_DIR}/librime/src"
1313
"${Opencc_INCLUDE_PATH}"
1414
)
15-
16-
17-
execute_process(
18-
COMMAND git --git-dir ${CMAKE_SOURCE_DIR}/../../../../.git describe --tags
19-
OUTPUT_VARIABLE TRIME_VERSION
20-
)
21-
string(STRIP ${TRIME_VERSION} TRIME_VERSION)
22-
23-
target_compile_definitions(rime_jni PRIVATE
24-
TRIME_VERSION="${TRIME_VERSION}"
25-
)

app/src/main/jni/librime_jni/rime_jni.cc

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,16 @@ class Rime {
3838
if (!rime) return;
3939
const char *userDir = getenv("RIME_USER_DATA_DIR");
4040
const char *sharedDir = getenv("RIME_SHARED_DATA_DIR");
41+
const char *versionName = getenv("RIME_DISTRIBUTION_VERSION");
4142

4243
RIME_STRUCT(RimeTraits, trime_traits)
4344
trime_traits.shared_data_dir = sharedDir;
4445
trime_traits.user_data_dir = userDir;
4546
trime_traits.log_dir = ""; // set empty log_dir to log to logcat only
4647
trime_traits.app_name = "rime.trime";
47-
trime_traits.distribution_name = "Rime";
48+
trime_traits.distribution_name = "Trime";
4849
trime_traits.distribution_code_name = "trime";
49-
trime_traits.distribution_version = TRIME_VERSION;
50+
trime_traits.distribution_version = versionName;
5051

5152
if (firstRun) {
5253
rime->setup(&trime_traits);
@@ -176,11 +177,12 @@ JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *jvm, void *reserved) {
176177

177178
extern "C" JNIEXPORT void JNICALL Java_com_osfans_trime_core_Rime_startupRime(
178179
JNIEnv *env, jclass clazz, jstring shared_dir, jstring user_dir,
179-
jboolean full_check) {
180+
jstring version_name, jboolean full_check) {
180181
// for rime shared data dir
181182
setenv("RIME_SHARED_DATA_DIR", CString(env, shared_dir), 1);
182183
// for rime user data dir
183184
setenv("RIME_USER_DATA_DIR", CString(env, user_dir), 1);
185+
setenv("RIME_DISTRIBUTION_VERSION", CString(env, version_name), 1);
184186

185187
auto notificationHandler = [](void *context_object, RimeSessionId session_id,
186188
const char *message_type,

0 commit comments

Comments
 (0)