From e5d7003b02c9af96c51ea5638e07eea25057a216 Mon Sep 17 00:00:00 2001 From: dundargoc <33953936+dundargoc@users.noreply.github.com> Date: Mon, 4 Dec 2023 20:21:38 +0100 Subject: build: rework formatting to use add_glob_target This will ensure that we can pass flags and make adjustments from the top level cmake file instead of digging through the cmake directory. More importantly, this will only format files that have been changed. This has a slightly higher initial cost compared to previous solution as all files must be initially formatted, but the gained speed up should more than make up for it quickly. `make formatlua` is always run due to a quirk of stylua of always changing modification time of the file regardless if there were any changes. This is not a major blocker as stylua is very fast. --- src/nvim/CMakeLists.txt | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/nvim/CMakeLists.txt b/src/nvim/CMakeLists.txt index 6a01632040..0cdce539eb 100644 --- a/src/nvim/CMakeLists.txt +++ b/src/nvim/CMakeLists.txt @@ -879,12 +879,11 @@ add_glob_target( FLAGS -c ${UNCRUSTIFY_CONFIG} -q --check FILES ${LINT_NVIM_SOURCES}) -add_custom_target(formatc - COMMAND ${CMAKE_COMMAND} - -D FORMAT_PRG=${UNCRUSTIFY_PRG} - -D LANG=c - -P ${PROJECT_SOURCE_DIR}/cmake/Format.cmake - WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}) +add_glob_target( + TARGET formatc + COMMAND ${UNCRUSTIFY_PRG} + FLAGS -c ${UNCRUSTIFY_CONFIG} --replace --no-backup + FILES ${LINT_NVIM_SOURCES}) add_dependencies(lintc-uncrustify uncrustify_update_config) add_dependencies(formatc uncrustify_update_config) -- cgit