From d75496550719ae6e1538fe4af5f6ebea41666464 Mon Sep 17 00:00:00 2001 From: Jens Georg <jens.georg@desy.de> Date: Mon, 8 Aug 2022 16:29:53 +0200 Subject: [PATCH] Ignore files generated by CMake during configure There are a couple of files in the CMakeFiles folder that will match the search patterns. This is problematic during package build, since debian builds in a subfolder of the source folder, so we hit those files and tests fail --- cmake/check-coding-style.sh | 12 +++++++++--- cmake/enable_code_style_check.cmake | 2 +- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/cmake/check-coding-style.sh b/cmake/check-coding-style.sh index 2161c99..77e086e 100755 --- a/cmake/check-coding-style.sh +++ b/cmake/check-coding-style.sh @@ -4,9 +4,15 @@ ERRFILE=`mktemp` export ERRFILE echo 0 > "${ERRFILE}" +# This is necessary to get the two paths to match up, since we get a full path from cmake +mypath=$(pwd) +mypath=$(realpath $mypath) +exclude_path=${1:-justignoreme} +exclude_pattern="$exclude_path/*" + # check clang-format formatting if which clang-format-14 > /dev/null; then - find \( -name *.cc -o -name *.cpp -o -name *.h \) -exec clang-format-14 --output-replacements-xml \{\} \; | grep "^<replacement " > /dev/null + find $mypath \( -name *.cc -o -name *.cpp -o -name *.h \) -not -path "$exclude_pattern" -exec clang-format-14 --output-replacements-xml \{\} \; | grep "^<replacement " > /dev/null if [ $? -ne 1 ]; then echo 1 > "${ERRFILE}" echo "Code formatting incorrect!" @@ -30,7 +36,7 @@ checkCopyrightComment() { fi } export -f checkCopyrightComment -find \( -name *.cc -o -name *.cpp -o -name *.h \) -exec bash -c 'checkCopyrightComment {}' \; +find $mypath \( -name *.cc -o -name *.cpp -o -name *.h \) -not -path "$exclude_pattern" -exec bash -c 'checkCopyrightComment {}' \; # check all header files for "#pragma once" in 3rd line checkPramgaOnce() { @@ -40,7 +46,7 @@ checkPramgaOnce() { fi } export -f checkPramgaOnce -find -name *.h -exec bash -c 'checkPramgaOnce {}' \; +find $mypath -name *.h -not -path "$exclude_pattern" -exec bash -c 'checkPramgaOnce {}' \; ERROR=`cat "${ERRFILE}"` rm -f "${ERRFILE}" diff --git a/cmake/enable_code_style_check.cmake b/cmake/enable_code_style_check.cmake index 735d42c..efac67d 100644 --- a/cmake/enable_code_style_check.cmake +++ b/cmake/enable_code_style_check.cmake @@ -18,5 +18,5 @@ ####################################################################################################################### enable_testing() -add_test(NAME coding_style COMMAND ${CMAKE_SOURCE_DIR}/cmake/check-coding-style.sh +add_test(NAME coding_style COMMAND ${CMAKE_SOURCE_DIR}/cmake/check-coding-style.sh ${CMAKE_BINARY_DIR} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) -- GitLab