diff options
author | dundargoc <33953936+dundargoc@users.noreply.github.com> | 2022-06-09 17:09:24 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-09 08:09:24 -0700 |
commit | 6d57bb89c1ee376b60198f4a4b75430905844138 (patch) | |
tree | 5e9b522be1202cedd601e01a983cc7893b581bf4 /cmake | |
parent | 9662cd7f48c5dc3b7ab5f5ca3e5b217a03faa6c9 (diff) | |
download | rneovim-6d57bb89c1ee376b60198f4a4b75430905844138.tar.gz rneovim-6d57bb89c1ee376b60198f4a4b75430905844138.tar.bz2 rneovim-6d57bb89c1ee376b60198f4a4b75430905844138.zip |
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.
Diffstat (limited to 'cmake')
-rw-r--r-- | cmake/lint.cmake | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/cmake/lint.cmake b/cmake/lint.cmake new file mode 100644 index 0000000000..1fb8c749a8 --- /dev/null +++ b/cmake/lint.cmake @@ -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() |