mirror of
https://github.com/neovim/neovim.git
synced 2024-12-19 18:55:14 -07:00
build: replace check-single-includes with clang-tidy (#22061)
Clang-tidy already does what check-single-includes does automatically on top of its regular linting. It is also generator independent, so it doesn't take an eternity to run on slower generators such as Visual Studio.
This commit is contained in:
parent
f4c836ad70
commit
d6d3a92013
3
.github/workflows/ci.yml
vendored
3
.github/workflows/ci.yml
vendored
@ -171,8 +171,7 @@ jobs:
|
|||||||
run: cmake --build build --target lintc-clint
|
run: cmake --build build --target lintc-clint
|
||||||
|
|
||||||
- if: success() || failure() && steps.abort_job.outputs.status == 'success'
|
- if: success() || failure() && steps.abort_job.outputs.status == 'success'
|
||||||
name: check-single-includes
|
run: cmake --build build --target clang-tidy
|
||||||
run: make check-single-includes
|
|
||||||
|
|
||||||
- name: Cache dependencies
|
- name: Cache dependencies
|
||||||
run: ./ci/before_cache.sh
|
run: ./ci/before_cache.sh
|
||||||
|
@ -244,9 +244,9 @@ endif()
|
|||||||
# Lint
|
# Lint
|
||||||
#
|
#
|
||||||
find_program(LUACHECK_PRG luacheck)
|
find_program(LUACHECK_PRG luacheck)
|
||||||
|
find_program(SHELLCHECK_PRG shellcheck)
|
||||||
find_program(STYLUA_PRG stylua)
|
find_program(STYLUA_PRG stylua)
|
||||||
find_program(UNCRUSTIFY_PRG uncrustify)
|
find_program(UNCRUSTIFY_PRG uncrustify)
|
||||||
find_program(SHELLCHECK_PRG shellcheck)
|
|
||||||
|
|
||||||
add_glob_target(
|
add_glob_target(
|
||||||
REQUIRED
|
REQUIRED
|
||||||
@ -287,7 +287,7 @@ add_custom_target(lintcommit
|
|||||||
add_dependencies(lintcommit nvim)
|
add_dependencies(lintcommit nvim)
|
||||||
|
|
||||||
add_custom_target(lint)
|
add_custom_target(lint)
|
||||||
add_dependencies(lint check-single-includes lintc lintlua lintsh lintcommit)
|
add_dependencies(lint clang-tidy lintc lintlua lintsh lintcommit)
|
||||||
|
|
||||||
#
|
#
|
||||||
# Format
|
# Format
|
||||||
|
2
Makefile
2
Makefile
@ -130,7 +130,7 @@ functionaltest-lua: | nvim
|
|||||||
$(BUILD_TOOL) -C build $@
|
$(BUILD_TOOL) -C build $@
|
||||||
|
|
||||||
FORMAT=formatc formatlua format
|
FORMAT=formatc formatlua format
|
||||||
LINT=lintlua lintsh lintc check-single-includes lintcommit lint
|
LINT=lintlua lintsh lintc clang-tidy lintcommit lint
|
||||||
TEST=functionaltest unittest
|
TEST=functionaltest unittest
|
||||||
generated-sources benchmark uninstall $(FORMAT) $(LINT) $(TEST): | build/.ran-cmake
|
generated-sources benchmark uninstall $(FORMAT) $(LINT) $(TEST): | build/.ran-cmake
|
||||||
$(CMAKE_PRG) --build build --target $@
|
$(CMAKE_PRG) --build build --target $@
|
||||||
|
@ -878,44 +878,35 @@ function(get_test_target prefix sfile relative_path_var target_var)
|
|||||||
endif()
|
endif()
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
|
find_program(CLANG_TIDY_PRG clang-tidy)
|
||||||
|
set(EXCLUDE_CLANG_TIDY typval_encode.c.h ui_events.in.h)
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
set(NO_SINGLE_CHECK_HEADERS
|
list(APPEND EXCLUDE_CLANG_TIDY
|
||||||
os/pty_process_unix.h
|
os/pty_process_unix.h
|
||||||
os/unix_defs.h)
|
os/unix_defs.h)
|
||||||
else()
|
else()
|
||||||
set(NO_SINGLE_CHECK_HEADERS
|
list(APPEND EXCLUDE_CLANG_TIDY
|
||||||
os/win_defs.h
|
os/win_defs.h
|
||||||
os/pty_process_win.h
|
os/pty_process_win.h
|
||||||
os/pty_conpty_win.h
|
os/pty_conpty_win.h
|
||||||
os/os_win_console.h)
|
os/os_win_console.h)
|
||||||
endif()
|
endif()
|
||||||
foreach(hfile ${NVIM_HEADERS})
|
add_glob_target(
|
||||||
get_test_target(test-includes "${hfile}" relative_path texe)
|
TARGET clang-tidy
|
||||||
|
COMMAND ${CLANG_TIDY_PRG}
|
||||||
if(NOT ${hfile} MATCHES "[.](c|in)[.]h$")
|
FILES ${NVIM_SOURCES} ${NVIM_HEADERS}
|
||||||
set(tsource "${GENERATED_DIR}/${relative_path}.test-include.c")
|
FLAGS --quiet
|
||||||
write_file("${tsource}" "#include \"${hfile}\"\nint main(int argc, char **argv) { return 0; }")
|
EXCLUDE ${EXCLUDE_CLANG_TIDY})
|
||||||
add_executable(
|
add_custom_target(copy_compile_commands
|
||||||
${texe}
|
COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_BINARY_DIR}/compile_commands.json ${PROJECT_SOURCE_DIR}/compile_commands.json)
|
||||||
EXCLUDE_FROM_ALL
|
add_dependencies(copy_compile_commands nvim)
|
||||||
${tsource} ${NVIM_HEADERS} ${NVIM_GENERATED_FOR_HEADERS})
|
add_dependencies(clang-tidy copy_compile_commands)
|
||||||
target_link_libraries(${texe} PRIVATE main_lib)
|
|
||||||
set_target_properties(${texe} PROPERTIES FOLDER test)
|
|
||||||
|
|
||||||
list(FIND NO_SINGLE_CHECK_HEADERS "${relative_path}" hfile_exclude_idx)
|
|
||||||
if(${hfile_exclude_idx} EQUAL -1)
|
|
||||||
list(APPEND HEADER_CHECK_TARGETS ${texe})
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
endforeach()
|
|
||||||
add_custom_target(check-single-includes DEPENDS ${HEADER_CHECK_TARGETS})
|
|
||||||
|
|
||||||
if(CI_BUILD)
|
if(CI_BUILD)
|
||||||
set(LINT_OUTPUT_FORMAT gh_action)
|
set(LINT_OUTPUT_FORMAT gh_action)
|
||||||
else()
|
else()
|
||||||
set(LINT_OUTPUT_FORMAT vs7)
|
set(LINT_OUTPUT_FORMAT vs7)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_glob_target(
|
add_glob_target(
|
||||||
TARGET lintc-clint
|
TARGET lintc-clint
|
||||||
COMMAND ${PROJECT_SOURCE_DIR}/src/clint.py
|
COMMAND ${PROJECT_SOURCE_DIR}/src/clint.py
|
||||||
|
Loading…
Reference in New Issue
Block a user