Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added librime-lua version function : rime_api.get_rime_lua_version() #386

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
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
14 changes: 14 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,20 @@ endif()
aux_source_directory(src RIME_LUA_SRC)
aux_source_directory(src/lib RIME_LUA_LIB_SRC)


execute_process(
COMMAND git log -1 --format="%cs:%h"
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
OUTPUT_VARIABLE GIT_HASH
OUTPUT_STRIP_TRAILING_WHITESPACE
)

configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/src/git_version.h.in
${CMAKE_CURRENT_SOURCE_DIR}/src/git_version.h
@ONLY
)

add_library(rime-lua-objs OBJECT ${RIME_LUA_SRC} ${RIME_LUA_LIB_SRC} ${LUA_SRC})
if(BUILD_SHARED_LIBS)
set_target_properties(rime-lua-objs PROPERTIES POSITION_INDEPENDENT_CODE ON)
Expand Down
5 changes: 5 additions & 0 deletions src/git_version.h.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#ifndef GIT_VERSION_H
#define GIT_VERSION_H
#define GIT_HASH @GIT_HASH@

#endif // GIT_VERSION_H
6 changes: 6 additions & 0 deletions src/types.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

#include "lib/lua_export_type.h"
#include "optional.h"
#include "git_version.h"

#define ENABLE_TYPES_EXT

Expand Down Expand Up @@ -2384,8 +2385,13 @@ namespace RimeApiReg {
return boost::regex_replace(target, reg, fmt);
}

string get_rime_lua_version() {
return GIT_HASH;
}

static const luaL_Reg funcs[]= {
{ "get_rime_version", WRAP(get_rime_version) },
{ "get_rime_lua_version", WRAP(get_rime_lua_version) },
{ "get_shared_data_dir", WRAP(COMPAT<Deployer>::get_shared_data_dir) },
{ "get_user_data_dir", WRAP(COMPAT<Deployer>::get_user_data_dir) },
{ "get_sync_dir", WRAP(COMPAT<Deployer>::get_sync_dir) },
Expand Down