mirror of
https://github.com/neovim/neovim.git
synced 2024-12-19 10:45:16 -07:00
build: add a cmake target for all used linters #18543
* build: move the logic for linters to cmake Cmake is our source of truth. We should have as much of our build process there as possible so everyone can make use of it. * build: remove redundant check for ninja generator The minimum cmake version as of writing this is 3.10, which has ninja support.
This commit is contained in:
parent
9662cd7f48
commit
6d57bb89c1
18
.github/workflows/ci.yml
vendored
18
.github/workflows/ci.yml
vendored
@ -107,11 +107,11 @@ jobs:
|
||||
run: ./ci/run_tests.sh build_nvim
|
||||
|
||||
- if: "!cancelled()"
|
||||
name: clint-full
|
||||
run: ./ci/run_lint.sh clint-full
|
||||
name: lintcfull
|
||||
run: ./ci/run_lint.sh lintcfull
|
||||
|
||||
- if: "!cancelled()"
|
||||
name: stylua
|
||||
name: lintstylua
|
||||
uses: JohnnyMorganz/stylua-action@1.0.0
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
@ -124,16 +124,16 @@ jobs:
|
||||
git diff --color --exit-code
|
||||
|
||||
- if: "!cancelled()"
|
||||
name: lualint
|
||||
run: ./ci/run_lint.sh lualint
|
||||
name: lintlua
|
||||
run: ./ci/run_lint.sh lintlua
|
||||
|
||||
- if: "!cancelled()"
|
||||
name: pylint
|
||||
run: ./ci/run_lint.sh pylint
|
||||
name: lintpy
|
||||
run: ./ci/run_lint.sh lintpy
|
||||
|
||||
- if: "!cancelled()"
|
||||
name: shlint
|
||||
run: ./ci/run_lint.sh shlint
|
||||
name: lintsh
|
||||
run: ./ci/run_lint.sh lintsh
|
||||
|
||||
- if: "!cancelled()"
|
||||
name: check-single-includes
|
||||
|
@ -612,9 +612,6 @@ if(NOT BUSTED_OUTPUT_TYPE)
|
||||
set(BUSTED_OUTPUT_TYPE "nvim")
|
||||
endif()
|
||||
|
||||
find_program(LUACHECK_PRG luacheck)
|
||||
find_program(FLAKE8_PRG flake8)
|
||||
|
||||
include(InstallHelpers)
|
||||
|
||||
file(GLOB MANPAGES
|
||||
@ -748,15 +745,13 @@ if(BUSTED_LUA_PRG)
|
||||
set_target_properties(functionaltest-lua PROPERTIES FOLDER test)
|
||||
endif()
|
||||
|
||||
if(LUACHECK_PRG)
|
||||
add_custom_target(lualint
|
||||
COMMAND ${LUACHECK_PRG} -q runtime/ scripts/ src/ test/
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
else()
|
||||
add_custom_target(lualint false
|
||||
COMMENT "lualint: LUACHECK_PRG not defined")
|
||||
endif()
|
||||
|
||||
foreach(TARGET IN ITEMS lintlua lintsh lintpy lintuncrustify)
|
||||
add_custom_target(${TARGET}
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
-DPROJECT_ROOT=${PROJECT_SOURCE_DIR}
|
||||
-DTARGET=${TARGET}
|
||||
-P ${PROJECT_SOURCE_DIR}/cmake/lint.cmake)
|
||||
endforeach()
|
||||
|
||||
#add uninstall target
|
||||
if(NOT TARGET uninstall)
|
||||
|
66
Makefile
66
Makefile
@ -47,13 +47,7 @@ endif
|
||||
|
||||
ifeq (,$(BUILD_TOOL))
|
||||
ifeq (Ninja,$(CMAKE_GENERATOR))
|
||||
ifneq ($(shell $(CMAKE_PRG) --help 2>/dev/null | grep Ninja),)
|
||||
BUILD_TOOL = ninja
|
||||
else
|
||||
# User's version of CMake doesn't support Ninja
|
||||
BUILD_TOOL = $(MAKE)
|
||||
CMAKE_GENERATOR := Unix Makefiles
|
||||
endif
|
||||
BUILD_TOOL = ninja
|
||||
else
|
||||
BUILD_TOOL = $(MAKE)
|
||||
endif
|
||||
@ -140,51 +134,19 @@ build/runtime/doc/tags helptags: | nvim
|
||||
helphtml: | nvim build/runtime/doc/tags
|
||||
+$(BUILD_TOOL) -C build doc_html
|
||||
|
||||
functionaltest: | nvim
|
||||
+$(BUILD_TOOL) -C build functionaltest
|
||||
functionaltest functionaltest-lua unittest benchmark: | nvim
|
||||
$(BUILD_TOOL) -C build $@
|
||||
|
||||
functionaltest-lua: | nvim
|
||||
+$(BUILD_TOOL) -C build functionaltest-lua
|
||||
lintlua lintsh lintpy lintuncrustify lintc lintcfull check-single-includes generated-sources: | build/.ran-cmake
|
||||
$(CMAKE_PRG) --build build --target $@
|
||||
|
||||
stylua:
|
||||
stylua --check runtime/
|
||||
|
||||
lualint: | build/.ran-cmake deps
|
||||
$(BUILD_TOOL) -C build lualint
|
||||
|
||||
_opt_stylua:
|
||||
@command -v stylua && { $(MAKE) stylua; exit $$?; } \
|
||||
|| echo "SKIP: stylua (stylua not found)"
|
||||
|
||||
shlint:
|
||||
@shellcheck --version | head -n 2
|
||||
shellcheck scripts/vim-patch.sh
|
||||
|
||||
_opt_shlint:
|
||||
@command -v shellcheck && { $(MAKE) shlint; exit $$?; } \
|
||||
|| echo "SKIP: shlint (shellcheck not found)"
|
||||
|
||||
pylint:
|
||||
flake8 contrib/ scripts/ src/ test/
|
||||
|
||||
# Run pylint only if flake8 is installed.
|
||||
_opt_pylint:
|
||||
@command -v flake8 && { $(MAKE) pylint; exit $$?; } \
|
||||
|| echo "SKIP: pylint (flake8 not found)"
|
||||
|
||||
commitlint:
|
||||
commitlint: | nvim
|
||||
$(NVIM_PRG) -u NONE -es +"lua require('scripts.lintcommit').main({trace=false})"
|
||||
|
||||
_opt_commitlint:
|
||||
@test -x build/bin/nvim && { $(MAKE) commitlint; exit $$?; } \
|
||||
|| echo "SKIP: commitlint (build/bin/nvim not found)"
|
||||
|
||||
unittest: | nvim
|
||||
+$(BUILD_TOOL) -C build unittest
|
||||
|
||||
benchmark: | nvim
|
||||
+$(BUILD_TOOL) -C build benchmark
|
||||
|
||||
test: functionaltest unittest
|
||||
|
||||
clean:
|
||||
@ -200,18 +162,6 @@ distclean:
|
||||
install: checkprefix nvim
|
||||
+$(BUILD_TOOL) -C build install
|
||||
|
||||
clint: build/.ran-cmake
|
||||
+$(BUILD_TOOL) -C build clint
|
||||
|
||||
clint-full: build/.ran-cmake
|
||||
+$(BUILD_TOOL) -C build clint-full
|
||||
|
||||
check-single-includes: build/.ran-cmake
|
||||
+$(BUILD_TOOL) -C build check-single-includes
|
||||
|
||||
generated-sources: build/.ran-cmake
|
||||
+$(BUILD_TOOL) -C build generated-sources
|
||||
|
||||
appimage:
|
||||
bash scripts/genappimage.sh
|
||||
|
||||
@ -221,7 +171,7 @@ appimage:
|
||||
appimage-%:
|
||||
bash scripts/genappimage.sh $*
|
||||
|
||||
lint: check-single-includes clint _opt_stylua lualint _opt_pylint _opt_shlint _opt_commitlint
|
||||
lint: check-single-includes lintc lintlua lintpy lintsh _opt_commitlint lintuncrustify
|
||||
|
||||
# Generic pattern rules, allowing for `make build/bin/nvim` etc.
|
||||
# Does not work with "Unix Makefiles".
|
||||
@ -233,4 +183,4 @@ $(DEPS_BUILD_DIR)/%: phony_force
|
||||
$(BUILD_TOOL) -C $(DEPS_BUILD_DIR) $(patsubst $(DEPS_BUILD_DIR)/%,%,$@)
|
||||
endif
|
||||
|
||||
.PHONY: test stylua lualint pylint shlint functionaltest unittest lint clint clean distclean nvim libnvim cmake deps install appimage checkprefix commitlint
|
||||
.PHONY: test lintlua lintpy lintsh functionaltest unittest lint lintc clean distclean nvim libnvim cmake deps install appimage checkprefix commitlint
|
||||
|
@ -12,7 +12,7 @@ rm -f "$END_MARKER"
|
||||
|
||||
# Run all tests if no input argument is given
|
||||
if (($# == 0)); then
|
||||
tests=('clint-full' 'lualint' 'pylint' 'shlint' 'check-single-includes')
|
||||
tests=('lintcfull' 'lintlua' 'lintpy' 'lintsh' 'check-single-includes')
|
||||
else
|
||||
tests=("$@")
|
||||
fi
|
||||
|
34
cmake/lint.cmake
Normal file
34
cmake/lint.cmake
Normal file
@ -0,0 +1,34 @@
|
||||
function(lint)
|
||||
cmake_parse_arguments(LINT "QUIET" "PROGRAM" "FLAGS;FILES" ${ARGN})
|
||||
|
||||
if(LINT_QUIET)
|
||||
set(OUTPUT_QUIET OUTPUT_QUIET)
|
||||
elseif()
|
||||
set(OUTPUT_QUIET "")
|
||||
endif()
|
||||
|
||||
find_program(PROGRAM_EXISTS ${LINT_PROGRAM})
|
||||
if(PROGRAM_EXISTS)
|
||||
execute_process(COMMAND ${LINT_PROGRAM} ${LINT_FLAGS} ${LINT_FILES}
|
||||
WORKING_DIRECTORY ${PROJECT_ROOT}
|
||||
RESULT_VARIABLE ret
|
||||
${OUTPUT_QUIET})
|
||||
if(ret AND NOT ret EQUAL 0)
|
||||
message(FATAL_ERROR "FAILED: ${TARGET}")
|
||||
endif()
|
||||
else()
|
||||
message(STATUS "${TARGET}: ${LINT_PROGRAM} not found. SKIP.")
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
if(${TARGET} STREQUAL "lintuncrustify")
|
||||
file(GLOB_RECURSE FILES ${PROJECT_ROOT}/src/nvim/*.[c,h])
|
||||
lint(PROGRAM uncrustify FLAGS -c src/uncrustify.cfg -q --check FILES ${FILES} QUIET)
|
||||
elseif(${TARGET} STREQUAL "lintpy")
|
||||
lint(PROGRAM flake8 FILES contrib/ scripts/ src/ test/)
|
||||
elseif(${TARGET} STREQUAL "lintsh")
|
||||
lint(PROGRAM shellcheck FILES scripts/vim-patch.sh)
|
||||
elseif(${TARGET} STREQUAL "lintlua")
|
||||
lint(PROGRAM luacheck FLAGS -q FILES runtime/ scripts/ src/ test/)
|
||||
lint(PROGRAM stylua FLAGS --color=always --check FILES runtime/)
|
||||
endif()
|
@ -800,10 +800,10 @@ foreach(sfile ${LINT_NVIM_SOURCES})
|
||||
list(APPEND LINT_TARGETS ${touch_file})
|
||||
list(APPEND LINT_NVIM_REL_SOURCES ${rsfile})
|
||||
endforeach()
|
||||
add_custom_target(clint DEPENDS ${LINT_TARGETS})
|
||||
add_custom_target(lintc DEPENDS ${LINT_TARGETS})
|
||||
|
||||
add_custom_target(
|
||||
clint-full
|
||||
lintcfull
|
||||
COMMAND
|
||||
${LINT_PRG} --suppress-errors=${LINT_SUPPRESS_FILE} ${LINT_NVIM_REL_SOURCES}
|
||||
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
|
||||
|
@ -2307,6 +2307,7 @@ bool diff_find_change(win_T *wp, linenr_T lnum, int *startp, int *endp)
|
||||
|
||||
if ((dp == NULL) || (diff_check_sanity(curtab, dp) == FAIL)) {
|
||||
xfree(line_org);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user