diff --git a/cmake/CheckUncrustifyVersion.cmake b/cmake/CheckUncrustifyVersion.cmake new file mode 100644 index 0000000000..4812c24ace --- /dev/null +++ b/cmake/CheckUncrustifyVersion.cmake @@ -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() diff --git a/src/nvim/CMakeLists.txt b/src/nvim/CMakeLists.txt index 49d5f8a677..4b8774e598 100755 --- a/src/nvim/CMakeLists.txt +++ b/src/nvim/CMakeLists.txt @@ -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