diff options
author | zeertzjq <zeertzjq@outlook.com> | 2023-11-30 15:51:05 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-30 15:51:05 +0800 |
commit | 543e0256c19f397921a332e06b423215fd9aecb5 (patch) | |
tree | 5517c44128bc3a0763fc9789565b78c56e49d690 /src/nvim/generators/gen_declarations.lua | |
parent | 85be914879d49435c3b689efd5f1dae70e81d168 (diff) | |
download | rneovim-543e0256c19f397921a332e06b423215fd9aecb5.tar.gz rneovim-543e0256c19f397921a332e06b423215fd9aecb5.tar.bz2 rneovim-543e0256c19f397921a332e06b423215fd9aecb5.zip |
build: don't define FUNC_ATTR_* as empty in headers (#26317)
FUNC_ATTR_* should only be used in .c files with generated headers.
Defining FUNC_ATTR_* as empty in headers causes misuses of them to be
silently ignored. Instead don't define them by default, and only define
them as empty after a .c file has included its generated header.
Diffstat (limited to 'src/nvim/generators/gen_declarations.lua')
-rw-r--r-- | src/nvim/generators/gen_declarations.lua | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/src/nvim/generators/gen_declarations.lua b/src/nvim/generators/gen_declarations.lua index f9e9c6b0a8..fecca5191e 100644 --- a/src/nvim/generators/gen_declarations.lua +++ b/src/nvim/generators/gen_declarations.lua @@ -164,7 +164,7 @@ if fname == '--help' then print([[ Usage: - gendeclarations.lua definitions.c static.h non-static.h definitions.i + gen_declarations.lua definitions.c static.h non-static.h definitions.i Generates declarations for a C file definitions.c, putting declarations for static functions into static.h and declarations for non-static functions into @@ -202,17 +202,10 @@ local text = preproc_f:read("*all") preproc_f:close() -local header = [[ +local non_static = [[ #define DEFINE_FUNC_ATTRIBUTES #include "nvim/func_attr.h" #undef DEFINE_FUNC_ATTRIBUTES -]] - -local footer = [[ -#include "nvim/func_attr.h" -]] - -local non_static = header .. [[ #ifndef DLLEXPORT # ifdef MSWIN # define DLLEXPORT __declspec(dllexport) @@ -222,7 +215,20 @@ local non_static = header .. [[ #endif ]] -local static = header +local static = [[ +#define DEFINE_FUNC_ATTRIBUTES +#include "nvim/func_attr.h" +#undef DEFINE_FUNC_ATTRIBUTES +]] + +local non_static_footer = [[ +#include "nvim/func_attr.h" +]] + +local static_footer = [[ +#define DEFINE_EMPTY_ATTRIBUTES +#include "nvim/func_attr.h" // IWYU pragma: export +]] if fname:find('.*/src/nvim/.*%.c$') then -- Add an IWYU pragma comment if the corresponding .h file exists. @@ -307,8 +313,8 @@ while init ~= nil do end end -non_static = non_static .. footer -static = static .. footer +non_static = non_static .. non_static_footer +static = static .. static_footer local F F = io.open(static_fname, 'w') |