diff options
author | Josh Rahm <joshuarahm@gmail.com> | 2023-11-29 21:52:58 +0000 |
---|---|---|
committer | Josh Rahm <joshuarahm@gmail.com> | 2023-11-29 21:52:58 +0000 |
commit | 931bffbda3668ddc609fc1da8f9eb576b170aa52 (patch) | |
tree | d8c1843a95da5ea0bb4acc09f7e37843d9995c86 /src/nvim/generators/gen_declarations.lua | |
parent | 142d9041391780ac15b89886a54015fdc5c73995 (diff) | |
parent | 4a8bf24ac690004aedf5540fa440e788459e5e34 (diff) | |
download | rneovim-userreg.tar.gz rneovim-userreg.tar.bz2 rneovim-userreg.zip |
Merge remote-tracking branch 'upstream/master' into userreguserreg
Diffstat (limited to 'src/nvim/generators/gen_declarations.lua')
-rw-r--r--[-rwxr-xr-x] | src/nvim/generators/gen_declarations.lua | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/src/nvim/generators/gen_declarations.lua b/src/nvim/generators/gen_declarations.lua index 4097ff7dc5..f9e9c6b0a8 100755..100644 --- a/src/nvim/generators/gen_declarations.lua +++ b/src/nvim/generators/gen_declarations.lua @@ -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 @@ -174,7 +171,7 @@ static functions into static.h and declarations for non-static functions into non-static.h. File `definitions.i' should contain an already preprocessed version of definitions.c and it is the only one which is actually parsed, definitions.c is needed only to determine functions from which file out of all -functions found in definitions.i are needed. +functions found in definitions.i are needed and to generate an IWYU comment. Additionally uses the following environment variables: @@ -227,6 +224,18 @@ local non_static = header .. [[ local static = header +if fname:find('.*/src/nvim/.*%.c$') then + -- Add an IWYU pragma comment if the corresponding .h file exists. + local header_fname = fname:sub(1, -3) .. '.h' + local header_f = io.open(header_fname, 'r') + if header_f ~= nil then + header_f:close() + non_static = ([[ +// IWYU pragma: private, include "%s" +]]):format(header_fname:gsub('.*/src/nvim/', 'nvim/')) .. non_static + end +end + local filepattern = '^#%a* (%d+) "([^"]-)/?([^"/]+)"' local init = 1 @@ -244,12 +253,7 @@ while init ~= nil do curfile = file is_needed_file = (curfile == neededfile) declline = tonumber(line) - 1 - local curdir_start = dir:find('src/nvim/') - if curdir_start ~= nil then - curdir = dir:sub(curdir_start + #('src/nvim/')) - else - curdir = dir - end + curdir = dir:gsub('.*/src/nvim/', '') else declline = declline - 1 end @@ -311,7 +315,7 @@ F = io.open(static_fname, 'w') F:write(static) F:close() --- Before generating the non-static headers, check if the current file(if +-- Before generating the non-static headers, check if the current file (if -- exists) is different from the new one. If they are the same, we won't touch -- the current version to avoid triggering an unnecessary rebuilds of modules -- that depend on this one |