aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2024-07-16 06:08:16 +0800
committerGitHub <noreply@github.com>2024-07-16 06:08:16 +0800
commitb213f5169c33357d03012c52306789fd81a35b60 (patch)
tree12d4c7660ef04f1b1482efbada15078a119ea6f9
parent8703e7bd1215a1d67053fc189102391e57de6a78 (diff)
downloadrneovim-b213f5169c33357d03012c52306789fd81a35b60.tar.gz
rneovim-b213f5169c33357d03012c52306789fd81a35b60.tar.bz2
rneovim-b213f5169c33357d03012c52306789fd81a35b60.zip
build: allow comment after #include for required header (#29722)
And also check in .c files, as the attributes may be silently missing there as well.
-rw-r--r--src/nvim/CMakeLists.txt2
-rw-r--r--src/nvim/generators/gen_declarations.lua23
2 files changed, 16 insertions, 9 deletions
diff --git a/src/nvim/CMakeLists.txt b/src/nvim/CMakeLists.txt
index a5c7f313eb..eeb7e76616 100644
--- a/src/nvim/CMakeLists.txt
+++ b/src/nvim/CMakeLists.txt
@@ -545,7 +545,6 @@ foreach(sfile ${NVIM_SOURCES}
set(f "${d}/${f}")
set(r "${d}/${r}")
endif()
- set (gf_basename "")
if ("${ext}" STREQUAL ".c.h")
continue() # .c.h files are sussy baka, skip
elseif(${sfile} IN_LIST NVIM_HEADERS)
@@ -554,6 +553,7 @@ foreach(sfile ${NVIM_SOURCES}
set(gf_h_h "SKIP")
set(gf_h_h_out "")
else()
+ set(gf_basename "${r}.c.generated.h")
set(gf_c_h "${GENERATED_DIR}/${r}.c.generated.h")
set(gf_h_h "${GENERATED_INCLUDES_DIR}/${r}.h.generated.h")
set(gf_h_h_out "${gf_h_h}")
diff --git a/src/nvim/generators/gen_declarations.lua b/src/nvim/generators/gen_declarations.lua
index 3bba0aa4b9..f4d1d19481 100644
--- a/src/nvim/generators/gen_declarations.lua
+++ b/src/nvim/generators/gen_declarations.lua
@@ -208,6 +208,10 @@ if fname:find('.*/src/nvim/.*%.c$') then
// IWYU pragma: private, include "%s"
]]):format(header_fname:gsub('.*/src/nvim/', 'nvim/')) .. non_static
end
+elseif fname:find('.*/src/nvim/.*%.h$') then
+ static = ([[
+// IWYU pragma: private, include "%s"
+]]):format(fname:gsub('.*/src/nvim/', 'nvim/')) .. static
elseif non_static_fname:find('/include/api/private/dispatch_wrappers%.h%.generated%.h$') then
non_static = [[
// IWYU pragma: private, include "nvim/api/private/dispatch.h"
@@ -308,15 +312,18 @@ F = io.open(static_fname, 'w')
F:write(static)
F:close()
-if non_static_fname == 'SKIP' then
+if any_static then
F = io.open(fname, 'r')
- if any_static then
- local orig_text = F:read('*a')
- local pat = '\n#%s?include%s+"' .. static_basename .. '"\n'
- if not string.find(orig_text, pat) then
- error('fail: missing include for ' .. static_basename .. ' in ' .. fname)
- end
+ local orig_text = F:read('*a')
+ local pat = '\n#%s?include%s+"' .. static_basename .. '"\n'
+ local pat_comment = '\n#%s?include%s+"' .. static_basename .. '"%s*//'
+ if not string.find(orig_text, pat) and not string.find(orig_text, pat_comment) then
+ error('fail: missing include for ' .. static_basename .. ' in ' .. fname)
end
+ F:close()
+end
+
+if non_static_fname == 'SKIP' then
return -- only want static declarations
end
@@ -329,7 +336,7 @@ if F ~= nil then
if F:read('*a') == non_static then
os.exit(0)
end
- io.close(F)
+ F:close()
end
F = io.open(non_static_fname, 'w')