Skip to content

Commit

Permalink
add jit.vmdef when statically building luajit
Browse files Browse the repository at this point in the history
  • Loading branch information
truemedian authored and zhaozg committed Jul 4, 2024
1 parent bdb3d27 commit eaf48f2
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ else (WithSharedLibluv)
else ()
include_directories(deps/luv/deps/luajit/src)
list(APPEND LUVI_LIBRARIES luajit-5.1)

set(luajit_vmdef ${CMAKE_CURRENT_BINARY_DIR}/deps/luv/vmdef.lua)
set_source_files_properties(${luajit_vmdef} PROPERTIES GENERATED TRUE)

list(APPEND LUVI_DEFINITIONS WITH_LJ_VMDEF)
endif ()

list(APPEND LUVI_LIBRARIES libluv_a uv_a)
Expand Down Expand Up @@ -134,6 +139,7 @@ lua_add_executable(luvi
src/lua/init.lua
src/lua/luvipath.lua
src/lua/luvibundle.lua
${luajit_vmdef}
${lpeg_re_lua}
)

Expand Down
3 changes: 3 additions & 0 deletions src/luvi.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ int luaopen_lpeg(lua_State* L);
#ifdef WITH_PLAIN_LUA
LUALIB_API int luaopen_bit(lua_State *L);
#endif
#ifdef WITH_LJ_VMDEF
LUALIB_API int luaopen_vmdef(lua_State *L);
#endif

void luvi_openlibs(lua_State *L);

Expand Down
5 changes: 5 additions & 0 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,11 @@ static lua_State* vm_acquire(){
lua_pushcfunction(L, luaopen_luvipath);
lua_setfield(L, -2, "luvipath");

#ifdef WITH_LJ_VMDEF
lua_pushcfunction(L, luaopen_vmdef);
lua_setfield(L, -2, "jit.vmdef");
#endif

#ifdef WITH_CUSTOM
luvi_custom(L);
#endif
Expand Down

0 comments on commit eaf48f2

Please sign in to comment.