mirror of
https://github.com/neovim/neovim.git
synced 2024-12-19 02:34:59 -07:00
refactor(build): make all generated c files headers
There's no "rule" or bad practice or whatever that says we cannot generate c files. it is is just that we have ~20 generated headers and ~2 generated sources and there is nothing in these two generated source files which sets them aparts. Lua bindings are not different from rpc bindings, and pathdef is not different from versiondef. So to simplify build logic and ease the future port to build.zig, streamline the build to only have generated headers, no direct generated .c files. Also "nlua_add_api_functions" had its prototype duplicated twice which defeated the point of having mandatory prototypes (one source of truth).
This commit is contained in:
parent
435dee74bb
commit
3711a0387a
@ -194,6 +194,6 @@ file(GENERATE
|
||||
INPUT "${PROJECT_BINARY_DIR}/cmake.config/auto/versiondef.h.gen")
|
||||
|
||||
configure_file (
|
||||
"${PROJECT_SOURCE_DIR}/cmake.config/pathdef.c.in"
|
||||
"${PROJECT_BINARY_DIR}/cmake.config/auto/pathdef.c"
|
||||
"${PROJECT_SOURCE_DIR}/cmake.config/pathdef.h.in"
|
||||
"${PROJECT_BINARY_DIR}/cmake.config/auto/pathdef.h"
|
||||
ESCAPE_QUOTES)
|
||||
|
@ -1,4 +1,3 @@
|
||||
#include "${PROJECT_SOURCE_DIR}/src/nvim/vim_defs.h"
|
||||
char *default_vim_dir = "${CMAKE_INSTALL_FULL_DATAROOTDIR}/nvim";
|
||||
char *default_vimruntime_dir = "";
|
||||
char *default_lib_dir = "${CMAKE_INSTALL_FULL_LIBDIR}/nvim";
|
@ -327,7 +327,7 @@ set(GENERATED_UI_EVENTS_CALL ${GENERATED_DIR}/ui_events_call.generated.h)
|
||||
set(GENERATED_UI_EVENTS_CLIENT ${GENERATED_DIR}/ui_events_client.generated.h)
|
||||
set(GENERATED_UI_EVENTS_REMOTE ${GENERATED_DIR}/ui_events_remote.generated.h)
|
||||
set(GENERATED_UNICODE_TABLES ${GENERATED_DIR}/unicode_tables.generated.h)
|
||||
set(LUA_API_C_BINDINGS ${GENERATED_DIR}/lua_api_c_bindings.generated.c)
|
||||
set(LUA_API_C_BINDINGS ${GENERATED_DIR}/lua_api_c_bindings.generated.h)
|
||||
set(VIM_MODULE_FILE ${GENERATED_DIR}/lua/vim_module.generated.h)
|
||||
|
||||
# NVIM_RUNTIME_DIR
|
||||
@ -505,7 +505,6 @@ 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
|
||||
# These lists must be mutually exclusive.
|
||||
foreach(sfile ${NVIM_SOURCES}
|
||||
${GENERATED_API_DISPATCH}
|
||||
@ -620,10 +619,6 @@ add_custom_command(
|
||||
VERBATIM
|
||||
)
|
||||
|
||||
list(APPEND NVIM_GENERATED_SOURCES
|
||||
"${LUA_API_C_BINDINGS}"
|
||||
)
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT ${GENERATED_UI_EVENTS_CALL}
|
||||
${GENERATED_UI_EVENTS_REMOTE}
|
||||
@ -657,10 +652,7 @@ list(APPEND NVIM_GENERATED_FOR_SOURCES
|
||||
"${GENERATED_OPTIONS_MAP}"
|
||||
"${GENERATED_UNICODE_TABLES}"
|
||||
"${VIM_MODULE_FILE}"
|
||||
)
|
||||
|
||||
list(APPEND NVIM_GENERATED_SOURCES
|
||||
"${PROJECT_BINARY_DIR}/cmake.config/auto/pathdef.c"
|
||||
"${PROJECT_BINARY_DIR}/cmake.config/auto/pathdef.h"
|
||||
)
|
||||
|
||||
add_custom_command(OUTPUT ${GENERATED_EX_CMDS_ENUM} ${GENERATED_EX_CMDS_DEFS}
|
||||
@ -709,7 +701,6 @@ endif()
|
||||
target_sources(main_lib INTERFACE
|
||||
${NVIM_GENERATED_FOR_SOURCES}
|
||||
${NVIM_GENERATED_FOR_HEADERS}
|
||||
${NVIM_GENERATED_SOURCES}
|
||||
${NVIM_SOURCES}
|
||||
${NVIM_HEADERS}
|
||||
${EXTERNAL_SOURCES}
|
||||
@ -909,7 +900,6 @@ add_subdirectory(po)
|
||||
add_custom_target(generated-sources DEPENDS
|
||||
${NVIM_GENERATED_FOR_HEADERS}
|
||||
${NVIM_GENERATED_FOR_SOURCES}
|
||||
${NVIM_GENERATED_SOURCES}
|
||||
)
|
||||
|
||||
file(GLOB API_SOURCES CONFIGURE_DEPENDS ${PROJECT_SOURCE_DIR}/src/nvim/api/*.c)
|
||||
|
@ -716,23 +716,6 @@ end
|
||||
-- start building lua output
|
||||
output = assert(io.open(lua_c_bindings_outputf, 'wb'))
|
||||
|
||||
output:write([[
|
||||
#include <lua.h>
|
||||
#include <lualib.h>
|
||||
#include <lauxlib.h>
|
||||
|
||||
#include "nvim/ex_docmd.h"
|
||||
#include "nvim/ex_getln.h"
|
||||
#include "nvim/func_attr.h"
|
||||
#include "nvim/globals.h"
|
||||
#include "nvim/api/private/defs.h"
|
||||
#include "nvim/api/private/helpers.h"
|
||||
#include "nvim/api/private/dispatch.h"
|
||||
#include "nvim/lua/converter.h"
|
||||
#include "nvim/lua/executor.h"
|
||||
#include "nvim/memory.h"
|
||||
|
||||
]])
|
||||
include_headers(output, headers)
|
||||
output:write('\n')
|
||||
|
||||
@ -974,8 +957,6 @@ end
|
||||
|
||||
output:write(string.format(
|
||||
[[
|
||||
void nlua_add_api_functions(lua_State *lstate)
|
||||
REAL_FATTR_NONNULL_ALL;
|
||||
void nlua_add_api_functions(lua_State *lstate)
|
||||
{
|
||||
lua_createtable(lstate, 0, %u);
|
||||
|
18
src/nvim/lua/api_wrappers.c
Normal file
18
src/nvim/lua/api_wrappers.c
Normal file
@ -0,0 +1,18 @@
|
||||
#include <lauxlib.h>
|
||||
#include <lua.h>
|
||||
#include <lualib.h>
|
||||
|
||||
#include "nvim/api/private/defs.h"
|
||||
#include "nvim/api/private/dispatch.h"
|
||||
#include "nvim/api/private/helpers.h"
|
||||
#include "nvim/ex_docmd.h"
|
||||
#include "nvim/ex_getln.h"
|
||||
#include "nvim/func_attr.h"
|
||||
#include "nvim/globals.h"
|
||||
#include "nvim/lua/converter.h"
|
||||
#include "nvim/lua/executor.h"
|
||||
#include "nvim/memory.h"
|
||||
|
||||
#ifdef INCLUDE_GENERATED_DECLARATIONS
|
||||
# include "lua_api_c_bindings.generated.h"
|
||||
#endif
|
@ -12,7 +12,7 @@
|
||||
#include "nvim/types_defs.h"
|
||||
#include "nvim/usercmd.h" // IWYU pragma: keep
|
||||
|
||||
// Generated by msgpack-gen.lua
|
||||
// Generated by generators/gen_api_dispatch.lua
|
||||
void nlua_add_api_functions(lua_State *lstate) REAL_FATTR_NONNULL_ALL;
|
||||
|
||||
typedef struct {
|
||||
|
@ -49,6 +49,7 @@
|
||||
#endif
|
||||
|
||||
#ifdef INCLUDE_GENERATED_DECLARATIONS
|
||||
# include "auto/pathdef.h"
|
||||
# include "os/env.c.generated.h"
|
||||
#endif
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user