aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/generators/gen_api_dispatch.lua
diff options
context:
space:
mode:
authorbfredl <bjorn.linse@gmail.com>2023-04-15 12:23:45 +0200
committerbfredl <bjorn.linse@gmail.com>2023-04-19 10:44:25 +0200
commit1e60e8c0406f6b4b51c51abb5f53e25bd52fee5e (patch)
tree128b74d8aad120155ab6bbae0200a3221f18dc92 /src/nvim/generators/gen_api_dispatch.lua
parentcff02e993d920fa4bf0b5dc8b8f12d979850f049 (diff)
downloadrneovim-1e60e8c0406f6b4b51c51abb5f53e25bd52fee5e.tar.gz
rneovim-1e60e8c0406f6b4b51c51abb5f53e25bd52fee5e.tar.bz2
rneovim-1e60e8c0406f6b4b51c51abb5f53e25bd52fee5e.zip
refactor(build): use vendored versions of mpack and luabitop
Diffstat (limited to 'src/nvim/generators/gen_api_dispatch.lua')
-rw-r--r--src/nvim/generators/gen_api_dispatch.lua45
1 files changed, 14 insertions, 31 deletions
diff --git a/src/nvim/generators/gen_api_dispatch.lua b/src/nvim/generators/gen_api_dispatch.lua
index f292c265ec..ad7018e385 100644
--- a/src/nvim/generators/gen_api_dispatch.lua
+++ b/src/nvim/generators/gen_api_dispatch.lua
@@ -1,40 +1,23 @@
local mpack = require('mpack')
--- we need at least 4 arguments since the last two are output files
-if arg[1] == '--help' then
- print('Usage: genmsgpack.lua args')
- print('Args: 1: source directory')
- print(' 2: dispatch output file (dispatch_wrappers.generated.h)')
- print(' 3: functions metadata output file (funcs_metadata.generated.h)')
- print(' 4: API metadata output file (api_metadata.mpack)')
- print(' 5: lua C bindings output file (lua_api_c_bindings.generated.c)')
- print(' 6: keyset definitions output file (keysets_defs.generated.h)')
- print(' rest: C files where API functions are defined')
-end
-assert(#arg >= 4)
-local functions = {}
-
-local nvimdir = arg[1]
-package.path = nvimdir .. '/?.lua;' .. package.path
+local hashy = require'generators.hashy'
-_G.vim = loadfile(nvimdir..'/../../runtime/lua/vim/shared.lua')()
-_G.vim.inspect = loadfile(nvimdir..'/../../runtime/lua/vim/inspect.lua')()
+assert(#arg >= 5)
+-- output h file with generated dispatch functions (dispatch_wrappers.generated.h)
+local dispatch_outputf = arg[1]
+-- output h file with packed metadata (funcs_metadata.generated.h)
+local funcs_metadata_outputf = arg[2]
+-- output metadata mpack file, for use by other build scripts (api_metadata.mpack)
+local mpack_outputf = arg[3]
+local lua_c_bindings_outputf = arg[4] -- lua_api_c_bindings.generated.c
+local keysets_outputf = arg[5] -- keysets_defs.generated.h
-local hashy = require'generators.hashy'
+local functions = {}
-- names of all headers relative to the source root (for inclusion in the
-- generated file)
local headers = {}
--- output h file with generated dispatch functions
-local dispatch_outputf = arg[2]
--- output h file with packed metadata
-local funcs_metadata_outputf = arg[3]
--- output metadata mpack file, for use by other build scripts
-local mpack_outputf = arg[4]
-local lua_c_bindings_outputf = arg[5]
-local keysets_outputf = arg[6]
-
-- set of function names, used to detect duplicates
local function_names = {}
@@ -94,7 +77,7 @@ local function add_keyset(val)
end
-- read each input file, parse and append to the api metadata
-for i = 7, #arg do
+for i = 6, #arg do
local full_path = arg[i]
local parts = {}
for part in string.gmatch(full_path, '[^/]+') do
@@ -210,7 +193,7 @@ end
-- serialize the API metadata using msgpack and embed into the resulting
-- binary for easy querying by clients
local funcs_metadata_output = io.open(funcs_metadata_outputf, 'wb')
-local packed = mpack.pack(exported_functions)
+local packed = mpack.encode(exported_functions)
local dump_bin_array = require("generators.dump_bin_array")
dump_bin_array(funcs_metadata_output, 'funcs_metadata', packed)
funcs_metadata_output:close()
@@ -514,7 +497,7 @@ output:write(hashfun)
output:close()
local mpack_output = io.open(mpack_outputf, 'wb')
-mpack_output:write(mpack.pack(functions))
+mpack_output:write(mpack.encode(functions))
mpack_output:close()
local function include_headers(output_handle, headers_to_include)