mirror of
https://github.com/neovim/neovim.git
synced 2024-12-19 10:45:16 -07:00
build(cmake): simplify def_cmd_target function
Instead of appending to a command output, append to an existing target instead. The primary benefit is intermediary ...-cmd targets aren't needed, we can instead append commands to the relevant target directly.
This commit is contained in:
parent
cd1b2998d3
commit
636a309981
@ -618,20 +618,28 @@ find_program(SHELLCHECK_PRG shellcheck)
|
||||
include(DefCmdTarget)
|
||||
def_cmd_target(lintlua ${LUACHECK_PRG} LUACHECK_PRG true)
|
||||
if(LUACHECK_PRG)
|
||||
add_custom_command(OUTPUT lintlua-cmd APPEND COMMAND ${LUACHECK_PRG} -q runtime/ scripts/ src/ test/)
|
||||
add_custom_command(TARGET lintlua
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||
COMMAND ${LUACHECK_PRG} -q runtime/ scripts/ src/ test/)
|
||||
endif()
|
||||
if(STYLUA_PRG)
|
||||
add_custom_command(OUTPUT lintlua-cmd APPEND COMMAND ${STYLUA_PRG} --color=always --check runtime/)
|
||||
add_custom_command(TARGET lintlua
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||
COMMAND ${STYLUA_PRG} --color=always --check runtime/)
|
||||
else()
|
||||
add_custom_command(OUTPUT lintlua-cmd APPEND COMMAND ${CMAKE_COMMAND} -E echo "STYLUA_PRG not found")
|
||||
add_custom_command(TARGET lintlua COMMAND ${CMAKE_COMMAND} -E echo "STYLUA_PRG not found")
|
||||
endif()
|
||||
def_cmd_target(lintpy ${FLAKE8_PRG} FLAKE8_PRG false)
|
||||
if(FLAKE8_PRG)
|
||||
add_custom_command(OUTPUT lintpy-cmd APPEND COMMAND ${FLAKE8_PRG} contrib/ scripts/ src/ test/)
|
||||
add_custom_command(TARGET lintpy
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||
COMMAND ${FLAKE8_PRG} contrib/ scripts/ src/ test/)
|
||||
endif()
|
||||
def_cmd_target(lintsh ${SHELLCHECK_PRG} SHELLCHECK_PRG false)
|
||||
if(SHELLCHECK_PRG)
|
||||
add_custom_command(OUTPUT lintsh-cmd APPEND COMMAND ${SHELLCHECK_PRG} scripts/vim-patch.sh)
|
||||
add_custom_command(TARGET lintsh
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||
COMMAND ${SHELLCHECK_PRG} scripts/vim-patch.sh)
|
||||
endif()
|
||||
|
||||
include(InstallHelpers)
|
||||
|
@ -1,27 +1,19 @@
|
||||
# Defines a target named ${target} and a command with (symbolic) output
|
||||
# ${target}-cmd. If ${prg} is undefined the target prints "not found".
|
||||
# Defines a target named ${target}. 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.
|
||||
# - Use add_custom_command(TARGET <target_name> ...) to append a command to the
|
||||
# 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")
|
||||
add_custom_target(${target})
|
||||
|
||||
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
|
||||
if(NOT prg)
|
||||
if(prg_fatal)
|
||||
add_custom_command(TARGET ${target}
|
||||
COMMAND ${CMAKE_COMMAND} -E echo "${target}: ${prg_name} not found"
|
||||
COMMAND false)
|
||||
else()
|
||||
add_custom_command(TARGET ${target}
|
||||
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()
|
||||
|
@ -805,7 +805,7 @@ add_custom_target(lintc DEPENDS ${LINT_TARGETS})
|
||||
|
||||
def_cmd_target(lintuncrustify ${UNCRUSTIFY_PRG} UNCRUSTIFY_PRG false)
|
||||
if(UNCRUSTIFY_PRG)
|
||||
add_custom_command(OUTPUT lintuncrustify-cmd APPEND
|
||||
add_custom_command(TARGET lintuncrustify
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
-D UNCRUSTIFY_PRG=${UNCRUSTIFY_PRG}
|
||||
-D PROJECT_SOURCE_DIR=${PROJECT_SOURCE_DIR}
|
||||
|
Loading…
Reference in New Issue
Block a user