build(clint): more precise check for "defs" headers (#26236)

This commit is contained in:
zeertzjq 2023-11-27 08:34:06 +08:00 committed by GitHub
parent c2a5105e88
commit 7e2387f41b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 25 additions and 41 deletions

View File

@ -145,16 +145,12 @@ iwyu: build/.ran-cmake
|src/nvim/api/autocmd.h\ |src/nvim/api/autocmd.h\
|src/nvim/api/buffer.h\ |src/nvim/api/buffer.h\
|src/nvim/api/command.h\ |src/nvim/api/command.h\
|src/nvim/api/deprecated.h\
|src/nvim/api/extmark.h\ |src/nvim/api/extmark.h\
|src/nvim/api/keysets.h\
|src/nvim/api/options.h\ |src/nvim/api/options.h\
|src/nvim/api/private/converter.h\
|src/nvim/api/private/defs.h\ |src/nvim/api/private/defs.h\
|src/nvim/api/private/dispatch.h\ |src/nvim/api/private/dispatch.h\
|src/nvim/api/private/helpers.h\ |src/nvim/api/private/helpers.h\
|src/nvim/api/private/validate.h\ |src/nvim/api/private/validate.h\
|src/nvim/api/tabpage.h\
|src/nvim/api/ui.h\ |src/nvim/api/ui.h\
|src/nvim/api/vim.h\ |src/nvim/api/vim.h\
|src/nvim/api/vimscript.h\ |src/nvim/api/vimscript.h\
@ -226,7 +222,6 @@ iwyu: build/.ran-cmake
|src/nvim/fold_defs.h\ |src/nvim/fold_defs.h\
|src/nvim/garray.h\ |src/nvim/garray.h\
|src/nvim/getchar.h\ |src/nvim/getchar.h\
|src/nvim/getchar_defs.h\
|src/nvim/globals.h\ |src/nvim/globals.h\
|src/nvim/grid.h\ |src/nvim/grid.h\
|src/nvim/grid_defs.h\ |src/nvim/grid_defs.h\
@ -244,7 +239,6 @@ iwyu: build/.ran-cmake
|src/nvim/linematch.h\ |src/nvim/linematch.h\
|src/nvim/log.h\ |src/nvim/log.h\
|src/nvim/lua/base64.h\ |src/nvim/lua/base64.h\
|src/nvim/lua/converter.h\
|src/nvim/lua/executor.h\ |src/nvim/lua/executor.h\
|src/nvim/lua/secure.h\ |src/nvim/lua/secure.h\
|src/nvim/lua/spell.h\ |src/nvim/lua/spell.h\
@ -288,7 +282,6 @@ iwyu: build/.ran-cmake
|src/nvim/os/input.h\ |src/nvim/os/input.h\
|src/nvim/os/lang.h\ |src/nvim/os/lang.h\
|src/nvim/os/os.h\ |src/nvim/os/os.h\
|src/nvim/os/process.h\
|src/nvim/os/pty_conpty_win.h\ |src/nvim/os/pty_conpty_win.h\
|src/nvim/os/pty_process_unix.h\ |src/nvim/os/pty_process_unix.h\
|src/nvim/os/pty_process_win.h\ |src/nvim/os/pty_process_win.h\
@ -322,7 +315,6 @@ iwyu: build/.ran-cmake
|src/nvim/textformat.h\ |src/nvim/textformat.h\
|src/nvim/textobject.h\ |src/nvim/textobject.h\
|src/nvim/tui/input.h\ |src/nvim/tui/input.h\
|src/nvim/tui/terminfo.h\
|src/nvim/tui/tui.h\ |src/nvim/tui/tui.h\
|src/nvim/ugrid.h\ |src/nvim/ugrid.h\
|src/nvim/ui.h\ |src/nvim/ui.h\
@ -336,7 +328,6 @@ iwyu: build/.ran-cmake
|src/nvim/viml/parser/expressions.h\ |src/nvim/viml/parser/expressions.h\
|src/nvim/viml/parser/parser.h\ |src/nvim/viml/parser/parser.h\
|src/nvim/window.h\ |src/nvim/window.h\
|src/nvim/winfloat.h\
)" --nosafe_headers < build/iwyu.log )" --nosafe_headers < build/iwyu.log
cmake -B build -U ENABLE_IWYU cmake -B build -U ENABLE_IWYU
cmake --build build cmake --build build

View File

@ -890,6 +890,7 @@ def CheckIncludes(filename, lines, error):
""" """
if filename.endswith('.c.h') or filename.endswith('.in.h') or FileInfo(filename).RelativePath() in { if filename.endswith('.c.h') or filename.endswith('.in.h') or FileInfo(filename).RelativePath() in {
'func_attr.h', 'func_attr.h',
'os/pty_process.h',
}: }:
return return
@ -899,16 +900,12 @@ def CheckIncludes(filename, lines, error):
"src/nvim/api/autocmd.h", "src/nvim/api/autocmd.h",
"src/nvim/api/buffer.h", "src/nvim/api/buffer.h",
"src/nvim/api/command.h", "src/nvim/api/command.h",
"src/nvim/api/deprecated.h",
"src/nvim/api/extmark.h", "src/nvim/api/extmark.h",
"src/nvim/api/keysets.h",
"src/nvim/api/options.h", "src/nvim/api/options.h",
"src/nvim/api/private/converter.h",
"src/nvim/api/private/defs.h", "src/nvim/api/private/defs.h",
"src/nvim/api/private/dispatch.h", "src/nvim/api/private/dispatch.h",
"src/nvim/api/private/helpers.h", "src/nvim/api/private/helpers.h",
"src/nvim/api/private/validate.h", "src/nvim/api/private/validate.h",
"src/nvim/api/tabpage.h",
"src/nvim/api/ui.h", "src/nvim/api/ui.h",
"src/nvim/api/vim.h", "src/nvim/api/vim.h",
"src/nvim/api/vimscript.h", "src/nvim/api/vimscript.h",
@ -980,7 +977,6 @@ def CheckIncludes(filename, lines, error):
"src/nvim/fold_defs.h", "src/nvim/fold_defs.h",
"src/nvim/garray.h", "src/nvim/garray.h",
"src/nvim/getchar.h", "src/nvim/getchar.h",
"src/nvim/getchar_defs.h",
"src/nvim/globals.h", "src/nvim/globals.h",
"src/nvim/grid.h", "src/nvim/grid.h",
"src/nvim/grid_defs.h", "src/nvim/grid_defs.h",
@ -998,7 +994,6 @@ def CheckIncludes(filename, lines, error):
"src/nvim/linematch.h", "src/nvim/linematch.h",
"src/nvim/log.h", "src/nvim/log.h",
"src/nvim/lua/base64.h", "src/nvim/lua/base64.h",
"src/nvim/lua/converter.h",
"src/nvim/lua/executor.h", "src/nvim/lua/executor.h",
"src/nvim/lua/secure.h", "src/nvim/lua/secure.h",
"src/nvim/lua/spell.h", "src/nvim/lua/spell.h",
@ -1042,7 +1037,6 @@ def CheckIncludes(filename, lines, error):
"src/nvim/os/input.h", "src/nvim/os/input.h",
"src/nvim/os/lang.h", "src/nvim/os/lang.h",
"src/nvim/os/os.h", "src/nvim/os/os.h",
"src/nvim/os/process.h",
"src/nvim/os/pty_conpty_win.h", "src/nvim/os/pty_conpty_win.h",
"src/nvim/os/pty_process_unix.h", "src/nvim/os/pty_process_unix.h",
"src/nvim/os/pty_process_win.h", "src/nvim/os/pty_process_win.h",
@ -1076,7 +1070,6 @@ def CheckIncludes(filename, lines, error):
"src/nvim/textformat.h", "src/nvim/textformat.h",
"src/nvim/textobject.h", "src/nvim/textobject.h",
"src/nvim/tui/input.h", "src/nvim/tui/input.h",
"src/nvim/tui/terminfo.h",
"src/nvim/tui/tui.h", "src/nvim/tui/tui.h",
"src/nvim/ugrid.h", "src/nvim/ugrid.h",
"src/nvim/ui.h", "src/nvim/ui.h",
@ -1090,7 +1083,6 @@ def CheckIncludes(filename, lines, error):
"src/nvim/viml/parser/expressions.h", "src/nvim/viml/parser/expressions.h",
"src/nvim/viml/parser/parser.h", "src/nvim/viml/parser/parser.h",
"src/nvim/window.h", "src/nvim/window.h",
"src/nvim/winfloat.h",
] ]
for i in check_includes_ignore: for i in check_includes_ignore:
@ -1098,10 +1090,12 @@ def CheckIncludes(filename, lines, error):
return return
for i, line in enumerate(lines): for i, line in enumerate(lines):
if("#include" in line): matched = Match(r'#\s*include\s*"([^"]*)"$', line)
if("#include <" in line): if matched:
continue name = matched.group(1)
if "_defs" not in line: if (not name.endswith('.h.generated.h') and
not name.endswith('_defs.h') and
not name.endswith('/defs.h')):
error(filename, i, 'build/include_defs', 5, error(filename, i, 'build/include_defs', 5,
'Headers should not include non-"_defs" headers') 'Headers should not include non-"_defs" headers')

View File

@ -1,8 +1,8 @@
#pragma once #pragma once
#include <stdint.h> #include <stdint.h> // IWYU pragma: keep
#include "nvim/api/private/defs.h" #include "nvim/api/private/defs.h" // IWYU pragma: keep
#ifdef INCLUDE_GENERATED_DECLARATIONS #ifdef INCLUDE_GENERATED_DECLARATIONS
# include "api/deprecated.h.generated.h" # include "api/deprecated.h.generated.h"

View File

@ -1,7 +1,7 @@
#pragma once #pragma once
#include "nvim/api/private/defs.h" #include "nvim/api/private/defs.h" // IWYU pragma: keep
#include "nvim/eval/typval_defs.h" #include "nvim/eval/typval_defs.h" // IWYU pragma: keep
#ifdef INCLUDE_GENERATED_DECLARATIONS #ifdef INCLUDE_GENERATED_DECLARATIONS
# include "api/private/converter.h.generated.h" # include "api/private/converter.h.generated.h"

View File

@ -1,6 +1,6 @@
#pragma once #pragma once
#include "nvim/api/private/defs.h" #include "nvim/api/private/defs.h" // IWYU pragma: keep
#ifdef INCLUDE_GENERATED_DECLARATIONS #ifdef INCLUDE_GENERATED_DECLARATIONS
# include "api/tabpage.h.generated.h" # include "api/tabpage.h.generated.h"

View File

@ -1,12 +1,9 @@
#pragma once #pragma once
#include <lua.h> #include <lua.h> // IWYU pragma: keep
#include <stdbool.h>
#include <stdint.h>
#include "nvim/api/private/defs.h" #include "nvim/api/private/defs.h" // IWYU pragma: keep
#include "nvim/eval/typval_defs.h" #include "nvim/eval/typval_defs.h" // IWYU pragma: keep
#include "nvim/func_attr.h"
#define nlua_pop_Buffer nlua_pop_handle #define nlua_pop_Buffer nlua_pop_handle
#define nlua_pop_Window nlua_pop_handle #define nlua_pop_Window nlua_pop_handle

View File

@ -13,7 +13,7 @@
#include "nvim/pos.h" #include "nvim/pos.h"
#include "nvim/types.h" #include "nvim/types.h"
// only for debug functions: // only for debug functions:
#include "api/private/defs.h" #include "nvim/api/private/defs.h"
struct mtnode_s; struct mtnode_s;

View File

@ -1,8 +1,10 @@
#pragma once #pragma once
#include <stddef.h> #include <stddef.h> // IWYU pragma: keep
#include "nvim/api/private/defs.h" #ifdef MSWIN
# include "nvim/api/private/defs.h" // IWYU pragma: keep
#endif
#ifdef INCLUDE_GENERATED_DECLARATIONS #ifdef INCLUDE_GENERATED_DECLARATIONS
# include "os/process.h.generated.h" # include "os/process.h.generated.h"

View File

@ -1,6 +1,6 @@
#pragma once #pragma once
#include "nvim/garray_defs.h" // IWYU pragma: export #include "nvim/garray_defs.h" // IWYU pragma: keep
#ifdef INCLUDE_GENERATED_DECLARATIONS #ifdef INCLUDE_GENERATED_DECLARATIONS
# include "spellsuggest.h.generated.h" # include "spellsuggest.h.generated.h"

View File

@ -1,8 +1,8 @@
#pragma once #pragma once
#include <unibilium.h> #include <unibilium.h> // IWYU pragma: keep
#include "nvim/api/private/defs.h" #include "nvim/api/private/defs.h" // IWYU pragma: keep
#ifdef INCLUDE_GENERATED_DECLARATIONS #ifdef INCLUDE_GENERATED_DECLARATIONS
# include "tui/terminfo.h.generated.h" # include "tui/terminfo.h.generated.h"

View File

@ -1,7 +1,7 @@
#pragma once #pragma once
#include "nvim/api/private/defs.h" #include "nvim/api/private/defs.h" // IWYU pragma: keep
#include "nvim/buffer_defs.h" #include "nvim/buffer_defs.h" // IWYU pragma: keep
#ifdef INCLUDE_GENERATED_DECLARATIONS #ifdef INCLUDE_GENERATED_DECLARATIONS
# include "winfloat.h.generated.h" # include "winfloat.h.generated.h"