mirror of
https://github.com/neovim/neovim.git
synced 2025-12-13 10:02:49 +00: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:
@@ -618,20 +618,28 @@ find_program(SHELLCHECK_PRG shellcheck)
|
|||||||
include(DefCmdTarget)
|
include(DefCmdTarget)
|
||||||
def_cmd_target(lintlua ${LUACHECK_PRG} LUACHECK_PRG true)
|
def_cmd_target(lintlua ${LUACHECK_PRG} LUACHECK_PRG true)
|
||||||
if(LUACHECK_PRG)
|
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()
|
endif()
|
||||||
if(STYLUA_PRG)
|
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()
|
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()
|
endif()
|
||||||
def_cmd_target(lintpy ${FLAKE8_PRG} FLAKE8_PRG false)
|
def_cmd_target(lintpy ${FLAKE8_PRG} FLAKE8_PRG false)
|
||||||
if(FLAKE8_PRG)
|
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()
|
endif()
|
||||||
def_cmd_target(lintsh ${SHELLCHECK_PRG} SHELLCHECK_PRG false)
|
def_cmd_target(lintsh ${SHELLCHECK_PRG} SHELLCHECK_PRG false)
|
||||||
if(SHELLCHECK_PRG)
|
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()
|
endif()
|
||||||
|
|
||||||
include(InstallHelpers)
|
include(InstallHelpers)
|
||||||
|
|||||||
@@ -1,27 +1,19 @@
|
|||||||
# Defines a target named ${target} and a command with (symbolic) output
|
# Defines a target named ${target}. If ${prg} is undefined the target prints
|
||||||
# ${target}-cmd. If ${prg} is undefined the target prints "not found".
|
# "not found".
|
||||||
#
|
#
|
||||||
# - Use add_custom_command(…APPEND) to build the command after this.
|
# - Use add_custom_command(TARGET <target_name> ...) to append a command to the
|
||||||
# - Use add_custom_target(…DEPENDS) to run the command from a target.
|
# target.
|
||||||
function(def_cmd_target target prg prg_name prg_fatal)
|
function(def_cmd_target target prg prg_name prg_fatal)
|
||||||
# Define a mostly-empty command, which can be appended-to.
|
add_custom_target(${target})
|
||||||
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)
|
if(NOT prg)
|
||||||
add_custom_target(${target}
|
if(prg_fatal)
|
||||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
add_custom_command(TARGET ${target}
|
||||||
DEPENDS ${target}-cmd)
|
COMMAND ${CMAKE_COMMAND} -E echo "${target}: ${prg_name} not found"
|
||||||
if(NOT prg)
|
COMMAND false)
|
||||||
add_custom_command(OUTPUT ${target}-cmd APPEND
|
else()
|
||||||
|
add_custom_command(TARGET ${target}
|
||||||
COMMAND ${CMAKE_COMMAND} -E echo "${target}: SKIP: ${prg_name} not found")
|
COMMAND ${CMAKE_COMMAND} -E echo "${target}: SKIP: ${prg_name} not found")
|
||||||
endif()
|
endif()
|
||||||
else()
|
|
||||||
add_custom_target(${target} false
|
|
||||||
COMMENT "${target}: ${prg_name} not found")
|
|
||||||
endif()
|
endif()
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|||||||
@@ -805,7 +805,7 @@ add_custom_target(lintc DEPENDS ${LINT_TARGETS})
|
|||||||
|
|
||||||
def_cmd_target(lintuncrustify ${UNCRUSTIFY_PRG} UNCRUSTIFY_PRG false)
|
def_cmd_target(lintuncrustify ${UNCRUSTIFY_PRG} UNCRUSTIFY_PRG false)
|
||||||
if(UNCRUSTIFY_PRG)
|
if(UNCRUSTIFY_PRG)
|
||||||
add_custom_command(OUTPUT lintuncrustify-cmd APPEND
|
add_custom_command(TARGET lintuncrustify
|
||||||
COMMAND ${CMAKE_COMMAND}
|
COMMAND ${CMAKE_COMMAND}
|
||||||
-D UNCRUSTIFY_PRG=${UNCRUSTIFY_PRG}
|
-D UNCRUSTIFY_PRG=${UNCRUSTIFY_PRG}
|
||||||
-D PROJECT_SOURCE_DIR=${PROJECT_SOURCE_DIR}
|
-D PROJECT_SOURCE_DIR=${PROJECT_SOURCE_DIR}
|
||||||
|
|||||||
Reference in New Issue
Block a user