diff options
author | bfredl <bjorn.linse@gmail.com> | 2023-04-15 12:23:45 +0200 |
---|---|---|
committer | bfredl <bjorn.linse@gmail.com> | 2023-04-19 10:44:25 +0200 |
commit | 1e60e8c0406f6b4b51c51abb5f53e25bd52fee5e (patch) | |
tree | 128b74d8aad120155ab6bbae0200a3221f18dc92 /src/nvim/generators | |
parent | cff02e993d920fa4bf0b5dc8b8f12d979850f049 (diff) | |
download | rneovim-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')
-rw-r--r-- | src/nvim/generators/gen_api_dispatch.lua | 45 | ||||
-rwxr-xr-x | src/nvim/generators/gen_api_ui_events.lua | 18 | ||||
-rw-r--r-- | src/nvim/generators/gen_eval.lua | 29 | ||||
-rw-r--r-- | src/nvim/generators/gen_events.lua | 12 | ||||
-rw-r--r-- | src/nvim/generators/gen_ex_cmds.lua | 20 | ||||
-rw-r--r-- | src/nvim/generators/gen_options.lua | 10 | ||||
-rw-r--r-- | src/nvim/generators/preload.lua | 9 |
7 files changed, 44 insertions, 99 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) diff --git a/src/nvim/generators/gen_api_ui_events.lua b/src/nvim/generators/gen_api_ui_events.lua index bbc6252f14..c6a5d1d2a3 100755 --- a/src/nvim/generators/gen_api_ui_events.lua +++ b/src/nvim/generators/gen_api_ui_events.lua @@ -1,19 +1,15 @@ local mpack = require('mpack') -local nvimdir = arg[1] -package.path = nvimdir .. '/?.lua;' .. package.path - -assert(#arg == 6) -local input = io.open(arg[2], 'rb') -local call_output = io.open(arg[3], 'wb') -local remote_output = io.open(arg[4], 'wb') -local metadata_output = io.open(arg[5], 'wb') -local client_output = io.open(arg[6], 'wb') +assert(#arg == 5) +local input = io.open(arg[1], 'rb') +local call_output = io.open(arg[2], 'wb') +local remote_output = io.open(arg[3], 'wb') +local metadata_output = io.open(arg[4], 'wb') +local client_output = io.open(arg[5], 'wb') local c_grammar = require('generators.c_grammar') local events = c_grammar.grammar:match(input:read('*all')) -_G.vim = loadfile(nvimdir..'/../../runtime/lua/vim/shared.lua')() local hashy = require'generators.hashy' local function write_signature(output, ev, prefix, notype) @@ -194,7 +190,7 @@ for _,ev in ipairs(events) do end end -local packed = mpack.pack(exported_events) +local packed = mpack.encode(exported_events) local dump_bin_array = require("generators.dump_bin_array") dump_bin_array(metadata_output, 'ui_events_metadata', packed) metadata_output:close() diff --git a/src/nvim/generators/gen_eval.lua b/src/nvim/generators/gen_eval.lua index a86dc4233e..15e4c6540a 100644 --- a/src/nvim/generators/gen_eval.lua +++ b/src/nvim/generators/gen_eval.lua @@ -1,28 +1,13 @@ local mpack = require('mpack') -local nvimsrcdir = arg[1] -local shared_file = arg[2] -local autodir = arg[3] -local metadata_file = arg[4] -local funcs_file = arg[5] - -_G.vim = loadfile(shared_file)() - -if nvimsrcdir == '--help' then - print([[ -Usage: - lua gen_eval.lua src/nvim build/src/nvim/auto - -Will generate build/src/nvim/auto/funcs.generated.h with definition of functions -static const array. -]]) - os.exit(0) -end - -package.path = nvimsrcdir .. '/?.lua;' .. package.path +local autodir = arg[1] +local metadata_file = arg[2] +local funcs_file = arg[3] local funcsfname = autodir .. '/funcs.generated.h' +--Will generate funcs.generated.h with definition of functions static const array. + local hashy = require'generators.hashy' local hashpipe = io.open(funcsfname, 'wb') @@ -63,7 +48,7 @@ for _, func in pairs(funcs) do end end -local metadata = mpack.unpack(io.open(metadata_file, 'rb'):read("*all")) +local metadata = mpack.decode(io.open(metadata_file, 'rb'):read("*all")) for _,fun in ipairs(metadata) do if fun.eval then funcs[fun.name] = { @@ -77,7 +62,7 @@ end local func_names = vim.tbl_keys(funcs) table.sort(func_names) local funcsdata = io.open(funcs_file, 'w') -funcsdata:write(mpack.pack(func_names)) +funcsdata:write(mpack.encode(func_names)) funcsdata:close() local neworder, hashfun = hashy.hashy_hash("find_internal_func", func_names, function (idx) diff --git a/src/nvim/generators/gen_events.lua b/src/nvim/generators/gen_events.lua index 8db7f22452..27cec40b03 100644 --- a/src/nvim/generators/gen_events.lua +++ b/src/nvim/generators/gen_events.lua @@ -1,13 +1,5 @@ -if arg[1] == '--help' then - print('Usage: gen_events.lua src/nvim enum_file event_names_file') - os.exit(0) -end - -local nvimsrcdir = arg[1] -local fileio_enum_file = arg[2] -local names_file = arg[3] - -package.path = nvimsrcdir .. '/?.lua;' .. package.path +local fileio_enum_file = arg[1] +local names_file = arg[2] local auevents = require('auevents') local events = auevents.events diff --git a/src/nvim/generators/gen_ex_cmds.lua b/src/nvim/generators/gen_ex_cmds.lua index 26edd33604..76b372eac2 100644 --- a/src/nvim/generators/gen_ex_cmds.lua +++ b/src/nvim/generators/gen_ex_cmds.lua @@ -1,20 +1,8 @@ -local nvimsrcdir = arg[1] -local includedir = arg[2] -local autodir = arg[3] +local includedir = arg[1] +local autodir = arg[2] -if nvimsrcdir == '--help' then - print ([[ -Usage: - lua genex_cmds.lua src/nvim build/include build/src/nvim/auto - -Will generate files build/include/ex_cmds_enum.generated.h with cmdidx_T -enum and build/src/nvim/auto/ex_cmds_defs.generated.h with main Ex commands -definitions. -]]) - os.exit(0) -end - -package.path = nvimsrcdir .. '/?.lua;' .. package.path +-- Will generate files ex_cmds_enum.generated.h with cmdidx_T enum +-- and ex_cmds_defs.generated.h with main Ex commands definitions. local enumfname = includedir .. '/ex_cmds_enum.generated.h' local defsfname = autodir .. '/ex_cmds_defs.generated.h' diff --git a/src/nvim/generators/gen_options.lua b/src/nvim/generators/gen_options.lua index 54b97c5286..35302e1222 100644 --- a/src/nvim/generators/gen_options.lua +++ b/src/nvim/generators/gen_options.lua @@ -1,12 +1,4 @@ -if arg[1] == '--help' then - print('Usage: genoptions.lua src/nvim options_file') - os.exit(0) -end - -local nvimsrcdir = arg[1] -local options_file = arg[2] - -package.path = nvimsrcdir .. '/?.lua;' .. package.path +local options_file = arg[1] local opt_fd = io.open(options_file, 'w') diff --git a/src/nvim/generators/preload.lua b/src/nvim/generators/preload.lua new file mode 100644 index 0000000000..e5c8bd545b --- /dev/null +++ b/src/nvim/generators/preload.lua @@ -0,0 +1,9 @@ +local srcdir = table.remove(arg, 1) +local nlualib = table.remove(arg, 1) +package.path = srcdir .. '/src/nvim/?.lua;' ..srcdir .. '/runtime/lua/?.lua;' .. package.path +_G.vim = require'vim.shared' +_G.vim.inspect = require 'vim.inspect' +package.cpath = package.cpath .. ';' .. nlualib + +arg[0] = table.remove(arg, 1) +return loadfile(arg[0])() |