mirror of
https://github.com/neovim/neovim.git
synced 2025-10-08 10:56:31 +00:00
Merge pull request #23216 from bfredl/lpeg
refactor(build): include lpeg as a library
This commit is contained in:
@@ -9,5 +9,10 @@ LUA_API int luaopen_nlua0(lua_State* L) {
|
||||
luaopen_mpack(L);
|
||||
lua_setfield(L, -2, "mpack");
|
||||
|
||||
int luaopen_lpeg(lua_State *);
|
||||
luaopen_lpeg(L);
|
||||
lua_setfield(L, -3, "lpeg");
|
||||
lua_pop(L, 2);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@@ -26,6 +26,7 @@ target_include_directories(main_lib SYSTEM BEFORE INTERFACE ${LIBLUV_INCLUDE_DIR
|
||||
target_link_libraries(main_lib INTERFACE ${LIBLUV_LIBRARY})
|
||||
|
||||
find_package(Iconv REQUIRED)
|
||||
find_package(Lpeg REQUIRED)
|
||||
find_package(Libtermkey 0.22 REQUIRED)
|
||||
find_package(Libvterm 0.3 REQUIRED)
|
||||
find_package(Msgpack 1.0.0 REQUIRED)
|
||||
@@ -38,7 +39,9 @@ target_link_libraries(main_lib INTERFACE
|
||||
libvterm
|
||||
msgpack
|
||||
treesitter
|
||||
unibilium)
|
||||
unibilium
|
||||
lpeg)
|
||||
target_link_libraries(nlua0 PUBLIC lpeg)
|
||||
|
||||
# Libintl (not Intl) selects our FindLibintl.cmake script. #8464
|
||||
find_package(Libintl REQUIRED)
|
||||
@@ -324,6 +327,7 @@ if(PREFER_LUA)
|
||||
endif()
|
||||
|
||||
list(APPEND NLUA0_SOURCES ${PROJECT_SOURCE_DIR}/src/nlua0.c)
|
||||
|
||||
foreach(subdir
|
||||
os
|
||||
api
|
||||
@@ -443,6 +447,9 @@ add_custom_command(
|
||||
"${NVIM_VERSION_DEF_H}"
|
||||
DEPENDS "${PROJECT_BINARY_DIR}/cmake.config/auto/versiondef-$<CONFIG>.h")
|
||||
|
||||
set(LUA_GEN ${LUA_GEN_PRG} ${GENERATOR_PRELOAD} ${PROJECT_SOURCE_DIR} $<TARGET_FILE:nlua0>)
|
||||
set(LUA_GEN_DEPS ${GENERATOR_PRELOAD} $<TARGET_FILE:nlua0>)
|
||||
|
||||
# NVIM_GENERATED_FOR_HEADERS: generated headers to be included in headers
|
||||
# NVIM_GENERATED_FOR_SOURCES: generated headers to be included in sources
|
||||
# NVIM_GENERATED_SOURCES: generated source files
|
||||
@@ -476,7 +483,7 @@ foreach(sfile ${NVIM_SOURCES}
|
||||
set(PREPROC_OUTPUT -E -o ${gf_i})
|
||||
endif()
|
||||
|
||||
set(depends "${HEADER_GENERATOR}" "${sfile}")
|
||||
set(depends "${HEADER_GENERATOR}" "${sfile}" "${LUA_GEN_DEPS}")
|
||||
if("${f}" STREQUAL "version.c")
|
||||
# Ensure auto/versiondef_git.h exists after "make clean".
|
||||
list(APPEND depends update_version_stamp "${NVIM_VERSION_GIT_H}" "${NVIM_VERSION_DEF_H}")
|
||||
@@ -484,7 +491,7 @@ foreach(sfile ${NVIM_SOURCES}
|
||||
add_custom_command(
|
||||
OUTPUT "${gf_c_h}" "${gf_h_h}"
|
||||
COMMAND ${CMAKE_C_COMPILER} ${sfile} ${PREPROC_OUTPUT} ${gen_cflags}
|
||||
COMMAND "${LUA_PRG}" "${HEADER_GENERATOR}" "${sfile}" "${gf_c_h}" "${gf_h_h}" "${gf_i}"
|
||||
COMMAND ${LUA_GEN} "${HEADER_GENERATOR}" "${sfile}" "${gf_c_h}" "${gf_h_h}" "${gf_i}"
|
||||
DEPENDS ${depends})
|
||||
list(APPEND NVIM_GENERATED_FOR_SOURCES "${gf_c_h}")
|
||||
list(APPEND NVIM_GENERATED_FOR_HEADERS "${gf_h_h}")
|
||||
@@ -502,9 +509,6 @@ add_custom_command(OUTPUT ${GENERATED_UNICODE_TABLES}
|
||||
${UNICODE_FILES}
|
||||
)
|
||||
|
||||
set(LUA_GEN ${LUA_GEN_PRG} ${GENERATOR_PRELOAD} ${PROJECT_SOURCE_DIR} $<TARGET_FILE:nlua0>)
|
||||
set(LUA_GEN_DEPS ${GENERATOR_PRELOAD} $<TARGET_FILE:nlua0>)
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT ${GENERATED_API_DISPATCH} ${GENERATED_FUNCS_METADATA}
|
||||
${API_METADATA} ${LUA_API_C_BINDINGS} ${GENERATED_KEYSETS_DEFS}
|
||||
|
@@ -1,4 +1,4 @@
|
||||
local lpeg = require('lpeg')
|
||||
local lpeg = vim.lpeg
|
||||
|
||||
-- lpeg grammar for building api metadata from a set of header files. It
|
||||
-- ignores comments and preprocessor commands and parses a very small subset
|
||||
|
5
src/nvim/generators/gen_declarations.lua
Executable file → Normal file
5
src/nvim/generators/gen_declarations.lua
Executable file → Normal file
@@ -1,12 +1,9 @@
|
||||
#!/usr/bin/lua
|
||||
|
||||
local fname = arg[1]
|
||||
local static_fname = arg[2]
|
||||
local non_static_fname = arg[3]
|
||||
local preproc_fname = arg[4]
|
||||
|
||||
|
||||
local lpeg = require('lpeg')
|
||||
local lpeg = vim.lpeg
|
||||
|
||||
local fold = function (func, ...)
|
||||
local result = nil
|
||||
|
@@ -611,6 +611,19 @@ void nlua_state_add_stdlib(lua_State *const lstate, bool is_thread)
|
||||
lua_setfield(lstate, -2, "mpack");
|
||||
lua_pop(lstate, 3);
|
||||
|
||||
// vim.lpeg
|
||||
int luaopen_lpeg(lua_State *);
|
||||
luaopen_lpeg(lstate);
|
||||
lua_pushvalue(lstate, -1);
|
||||
lua_setfield(lstate, -4, "lpeg");
|
||||
|
||||
// package.loaded.lpeg = vim.lpeg
|
||||
lua_getglobal(lstate, "package");
|
||||
lua_getfield(lstate, -1, "loaded");
|
||||
lua_pushvalue(lstate, -3);
|
||||
lua_setfield(lstate, -2, "lpeg");
|
||||
lua_pop(lstate, 4);
|
||||
|
||||
// vim.diff
|
||||
lua_pushcfunction(lstate, &nlua_xdl_diff);
|
||||
lua_setfield(lstate, -2, "diff");
|
||||
|
Reference in New Issue
Block a user