diff --git a/CMakeLists.txt b/CMakeLists.txt index ff75973..edbd05b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -46,3 +46,17 @@ set(plugin_name "rime-lua" PARENT_SCOPE) set(plugin_objs $ PARENT_SCOPE) set(plugin_deps ${LUA_LIBRARIES} ${rime_library} ${rime_gears_library} PARENT_SCOPE) set(plugin_modules "lua" PARENT_SCOPE) + + +find_package(Git REQUIRED) +execute_process( + COMMAND ${GIT_EXECUTABLE} rev-parse --short HEAD + RESULT_VARIABLE result + OUTPUT_VARIABLE GIT_HASH ) + +set(librime_lua_version 1.0) +if(result AND result EQUAL 0) + set(librime_lua_version ${librime_lua_version}.${GIT_HASH}) +endif() +add_definitions(-DLIBRIME_LUA_VERSION="${librime_lua_version}") +message("Librime-lua Version: ${librime_lua_version}") diff --git a/src/types.cc b/src/types.cc index a8b73c4..0da9cd5 100644 --- a/src/types.cc +++ b/src/types.cc @@ -1697,6 +1697,9 @@ namespace RimeApiReg { RimeApi* rime = rime_get_api(); return string(rime->get_version()); } + string get_librime_lua_version() { + return LIBRIME_LUA_VERSION; + } string get_shared_data_dir() { RimeApi* rime = rime_get_api(); @@ -1762,6 +1765,7 @@ namespace RimeApiReg { static const luaL_Reg funcs[]= { { "get_rime_version", WRAP(get_rime_version) }, + { "get_librime_lua_version", WRAP(get_librime_lua_version) }, { "get_shared_data_dir", WRAP(get_shared_data_dir) }, { "get_user_data_dir", WRAP(get_user_data_dir) }, { "get_sync_dir", WRAP(get_sync_dir) },