diff --git a/CMakeLists.txt b/CMakeLists.txt index 2d396150..073f0107 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) @@ -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} ) diff --git a/src/luvi.h b/src/luvi.h index a1f827e7..8f39a9f7 100644 --- a/src/luvi.h +++ b/src/luvi.h @@ -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); diff --git a/src/main.c b/src/main.c index 3ea38be4..90629766 100644 --- a/src/main.c +++ b/src/main.c @@ -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