diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2022-06-13 00:08:01 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-12 15:08:01 -0700 |
commit | f90174c98cdc7af6c166043e15d178c619f83c99 (patch) | |
tree | 772ae1340aff4f426613d570d2cea17f231bbbfb /cmake | |
parent | 429c40cce3fce3b5391afef8208d65a80a316018 (diff) | |
download | rneovim-f90174c98cdc7af6c166043e15d178c619f83c99.tar.gz rneovim-f90174c98cdc7af6c166043e15d178c619f83c99.tar.bz2 rneovim-f90174c98cdc7af6c166043e15d178c619f83c99.zip |
build(lint): fix luacheck not found #18940
Problem:
Since 6d57bb89c1ee #18543, luacheck is not found on some systems when
running the "lintlua" target.
Solution:
- Move the find_program() to the top-level CMakeLists.txt
- Define a def_cmd_target() function with fewer assumptions than the old
lint() function.
- Move "lintuncrustify" to src/nvim/CMakeLists.txt so it can reuse the
$LINT_NVIM_SOURCES already defined there.
- Make the lint targets _fatal_ by default. There is little reason for
the "lint" umbrella target defined in Makefile to exist if it's going
to ignore the absence of the actual linters.
- For now, keep the uncrustify call in a separate cmake script so that
it can be silenced (too noisy).
Diffstat (limited to 'cmake')
-rw-r--r-- | cmake/DefCmdTarget.cmake | 27 | ||||
-rw-r--r-- | cmake/RunUncrustify.cmake | 5 | ||||
-rw-r--r-- | cmake/lint.cmake | 34 |
3 files changed, 32 insertions, 34 deletions
diff --git a/cmake/DefCmdTarget.cmake b/cmake/DefCmdTarget.cmake new file mode 100644 index 0000000000..1ee5cdd60e --- /dev/null +++ b/cmake/DefCmdTarget.cmake @@ -0,0 +1,27 @@ +# Defines a target named ${target} and a command with (symbolic) output +# ${target}-cmd. If ${prg} is undefined the target prints "not found". +# +# - Use add_custom_command(…APPEND) to build the command after this. +# - Use add_custom_target(…DEPENDS) to run the command from a target. +function(def_cmd_target target prg prg_name prg_fatal) + # Define a mostly-empty command, which can be appended-to. + add_custom_command(OUTPUT ${target}-cmd + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + COMMAND ${CMAKE_COMMAND} -E echo "${target}" + ) + # Symbolic (does not generate an artifact). + set_source_files_properties(${target}-cmd PROPERTIES SYMBOLIC "true") + + if(prg OR NOT prg_fatal) + add_custom_target(${target} + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + DEPENDS ${target}-cmd) + if(NOT prg) + add_custom_command(OUTPUT ${target}-cmd APPEND + COMMAND ${CMAKE_COMMAND} -E echo "${target}: SKIP: ${prg_name} not found") + endif() + else() + add_custom_target(${target} false + COMMENT "${target}: ${prg_name} not found") + endif() +endfunction() diff --git a/cmake/RunUncrustify.cmake b/cmake/RunUncrustify.cmake new file mode 100644 index 0000000000..9ebbd6b77c --- /dev/null +++ b/cmake/RunUncrustify.cmake @@ -0,0 +1,5 @@ +# HACK: This script is invoked with "cmake -P …" as a workaround to silence uncrustify. + +execute_process( + COMMAND ${UNCRUSTIFY_PRG} -c "${PROJECT_SOURCE_DIR}/src/uncrustify.cfg" -q --check ${LINT_NVIM_SOURCES} + OUTPUT_QUIET) diff --git a/cmake/lint.cmake b/cmake/lint.cmake deleted file mode 100644 index 1fb8c749a8..0000000000 --- a/cmake/lint.cmake +++ /dev/null @@ -1,34 +0,0 @@ -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() |