From 5068be6679f3e0480301f7e9df5b8147435cdcd4 Mon Sep 17 00:00:00 2001 From: Andrey Astafyev Date: Fri, 24 Dec 2021 07:18:29 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A6=D0=B5=D0=BB=D1=8C=20=D0=B4=D0=BB=D1=8F?= =?UTF-8?q?=20=D0=B0=D0=B2=D1=82=D0=BE=D0=BC=D0=B0=D1=82=D0=B8=D1=87=D0=B5?= =?UTF-8?q?=D1=81=D0=BA=D0=BE=D0=B3=D0=BE=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2?= =?UTF-8?q?=D0=BB=D0=B5=D0=BD=D0=B8=D1=8F=20=D1=88=D0=B0=D0=B1=D0=BB=D0=BE?= =?UTF-8?q?=D0=BD=D0=BE=D0=B2=20=D0=BA=D0=BE=D0=BC=D0=BC=D0=B5=D0=BD=D1=82?= =?UTF-8?q?=D0=B0=D1=80=D0=B8=D0=B5=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- MyxCMake/modules/MyxCMakeFormatSources.cmake | 51 +++++++++++++++----- 1 file changed, 38 insertions(+), 13 deletions(-) diff --git a/MyxCMake/modules/MyxCMakeFormatSources.cmake b/MyxCMake/modules/MyxCMakeFormatSources.cmake index 0b83440..42e278f 100644 --- a/MyxCMake/modules/MyxCMakeFormatSources.cmake +++ b/MyxCMake/modules/MyxCMakeFormatSources.cmake @@ -10,11 +10,11 @@ function(myx_cmake_format_sources target) if(NOT TARGET myx-cmake-format-sources) add_custom_target(myx-cmake-format-sources) endif() - if(NOT TARGET myx-cmake-check-format-sources) - add_custom_target(myx-cmake-check-format-sources) + if(NOT TARGET myx-cmake-format-sources-check) + add_custom_target(myx-cmake-format-sources-check) endif() - if(NOT TARGET myx-cmake-add-doxygen-comments) - add_custom_target(myx-cmake-add-doxygen-comments) + if(NOT TARGET myx-cmake-doc-doxygen-append-comments) + add_custom_target(myx-cmake-doc-doxygen-append-comments) endif() if(EXISTS ${CMAKE_SOURCE_DIR}/.uncrustify.cfg) @@ -22,28 +22,48 @@ function(myx_cmake_format_sources target) COMMAND ${UNCRUSTIFY_EXE} --update-config-with-doc -c ${CMAKE_SOURCE_DIR}/.uncrustify.cfg -o ${CMAKE_BINARY_DIR}/uncrustify.cfg) - list(APPEND UNCRUSTIFY_OPTS -L ERR -c ${CMAKE_BINARY_DIR}/uncrustify.cfg) + list(APPEND UNCRUSTIFY_OPTS -c ${CMAKE_BINARY_DIR}/uncrustify.cfg) endif() # cmake-format: off - add_custom_target(${target}-check-format-sources-uncrustify + add_custom_target(${target}-format-sources-check-uncrustify DEPENDS ${CMAKE_BINARY_DIR}/uncrustify.cfg COMMAND ${UNCRUSTIFY_EXE} ${UNCRUSTIFY_OPTS} --check ${__sources}) list(APPEND UNCRUSTIFY_OPTS --replace --no-backup) add_custom_target(${target}-format-sources-uncrustify DEPENDS ${CMAKE_BINARY_DIR}/uncrustify.cfg COMMAND ${UNCRUSTIFY_EXE} ${UNCRUSTIFY_OPTS} --mtime ${__sources}) - add_custom_target(${target}-add-doxygen-comments-uncrustify + file(GENERATE OUTPUT ${CMAKE_BINARY_DIR}/uncrustify-classheader.txt CONTENT +"/** + * @class $(fclass) + * @brief TODO + * @details TODO + */") + file(GENERATE OUTPUT ${CMAKE_BINARY_DIR}/uncrustify-filefooter.txt CONTENT + "// EOF $(filename)") + file(GENERATE OUTPUT ${CMAKE_BINARY_DIR}/uncrustify-fileheader.txt CONTENT +"/** + * @file $(filename) + * @brief TODO + * @details TODO + */") + file(GENERATE OUTPUT ${CMAKE_BINARY_DIR}/uncrustify-funcheader.txt CONTENT +"/** + * @fn $(fclass)::$(function) + * $(javaparam) + * @details TODO + */") + add_custom_target(${target}-doc-doxygen-append-comments DEPENDS ${CMAKE_BINARY_DIR}/uncrustify.cfg COMMAND ${UNCRUSTIFY_EXE} ${UNCRUSTIFY_OPTS} - --set cmt_insert_file_header=fileheader.txt - --set cmt_insert_file_footer=filefooter.txt - --set cmt_insert_func_header=funcheader.txt - --set cmt_insert_class_header=classheader.txt + --set cmt_insert_class_header=uncrustify-classheader.txt + --set cmt_insert_file_footer=uncrustify-filefooter.txt + --set cmt_insert_file_header=uncrustify-fileheader.txt + --set cmt_insert_func_header=uncrustify-funcheader.txt --set cmt_insert_before_ctor_dtor=true ${__sources}) # cmake-format: on - add_dependencies(myx-cmake-check-format-sources ${target}-check-format-sources-uncrustify) add_dependencies(myx-cmake-format-sources ${target}-format-sources-uncrustify) - add_dependencies(myx-cmake-add-doxygen-comments ${target}-add-doxygen-comments-uncrustify) + add_dependencies(myx-cmake-format-sources-check ${target}-format-sources-check-uncrustify) + add_dependencies(myx-cmake-doc-doxygen-append-comments ${target}-doc-doxygen-append-comments) else() message(STATUS "MyxCMake: uncrustify executable is not found") endif() @@ -56,4 +76,9 @@ function(myx_cmake_format_sources target) else() message(STATUS "MyxCMake: dos2unix executable is not found") endif() + + if(UNIX) + add_custom_target(${target}-format-sources-unexec COMMAND chmod -x ${__sources}) + add_dependencies(myx-cmake-format-sources ${target}-format-sources-unexec) + endif() endfunction()