build(lint): check uncrustify version #19468

This to prevent the user from accidentally using the wrong uncrustify
version.
This commit is contained in:
dundargoc 2022-07-25 15:18:49 +02:00 committed by GitHub
parent e12c62c1f7
commit e12035fc0c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 0 deletions

View File

@ -0,0 +1,13 @@
if(UNCRUSTIFY_PRG)
execute_process(COMMAND uncrustify --version
OUTPUT_VARIABLE user_version
OUTPUT_STRIP_TRAILING_WHITESPACE)
string(REGEX REPLACE "[A-Za-z_#-]" "" user_version ${user_version})
file(STRINGS ${CONFIG_FILE} required_version LIMIT_COUNT 1)
string(REGEX REPLACE "[A-Za-z_# -]" "" required_version ${required_version})
if(NOT user_version STREQUAL required_version)
message(FATAL_ERROR "Wrong uncrustify version! Required version is ${required_version} but found ${user_version}")
endif()
endif()

View File

@ -789,6 +789,12 @@ foreach(sfile ${LINT_NVIM_SOURCES})
endforeach()
add_custom_target(lintc DEPENDS ${LINT_TARGETS})
add_custom_target(uncrustify-version
COMMAND ${CMAKE_COMMAND}
-D UNCRUSTIFY_PRG=${UNCRUSTIFY_PRG}
-D CONFIG_FILE=${PROJECT_SOURCE_DIR}/src/uncrustify.cfg
-P ${PROJECT_SOURCE_DIR}/cmake/CheckUncrustifyVersion.cmake)
add_glob_targets(
TARGET lintuncrustify
COMMAND ${UNCRUSTIFY_PRG}
@ -796,6 +802,8 @@ add_glob_targets(
FILES ${LINT_NVIM_SOURCES}
)
add_dependencies(lintuncrustify uncrustify-version)
add_custom_target(
lintcfull
COMMAND