Start enforcing the clang-format rules on changed files
This commit is contained in:
+10
-2
@@ -17,9 +17,11 @@ variables:
|
|||||||
|
|
||||||
MAKE: make
|
MAKE: make
|
||||||
CONFIGURE: ./configure
|
CONFIGURE: ./configure
|
||||||
|
CLANG: clang-9
|
||||||
SCAN_BUILD: scan-build-9
|
SCAN_BUILD: scan-build-9
|
||||||
SYMBOLIZER: /usr/lib/llvm-9/bin/llvm-symbolizer
|
SYMBOLIZER: /usr/lib/llvm-9/bin/llvm-symbolizer
|
||||||
ASAN_SYMBOLIZER_PATH: "$SYMBOLIZER"
|
ASAN_SYMBOLIZER_PATH: "$SYMBOLIZER"
|
||||||
|
CLANG_FORMAT: clang-format-11
|
||||||
|
|
||||||
CFLAGS_COMMON: -fno-omit-frame-pointer -fno-optimize-sibling-calls -O1 -g -Wall -Wextra
|
CFLAGS_COMMON: -fno-omit-frame-pointer -fno-optimize-sibling-calls -O1 -g -Wall -Wextra
|
||||||
|
|
||||||
@@ -384,6 +386,12 @@ misc:sid:amd64:
|
|||||||
expire_in: "1 day"
|
expire_in: "1 day"
|
||||||
when: on_failure
|
when: on_failure
|
||||||
|
|
||||||
|
💾:sid:amd64:
|
||||||
|
<<: *precheck_job
|
||||||
|
script:
|
||||||
|
- if [ -r .clang-format ]; then ./util/cformat.sh "${CLANG_FORMAT}"; fi
|
||||||
|
- if test "$(git status --porcelain | grep -Ev '\?\?' | wc -l)" -gt "0"; then git status --short; exit 1; fi
|
||||||
|
|
||||||
🐞:sid:amd64:
|
🐞:sid:amd64:
|
||||||
<<: *precheck_job
|
<<: *precheck_job
|
||||||
<<: *debian_buster_amd64_image
|
<<: *debian_buster_amd64_image
|
||||||
@@ -618,7 +626,7 @@ scan-build:buster:amd64:
|
|||||||
<<: *debian_buster_amd64_image
|
<<: *debian_buster_amd64_image
|
||||||
stage: postcheck
|
stage: postcheck
|
||||||
variables:
|
variables:
|
||||||
CC: clang-9
|
CC: "${CLANG}"
|
||||||
CFLAGS: "${CFLAGS_COMMON}"
|
CFLAGS: "${CFLAGS_COMMON}"
|
||||||
CONFIGURE: "${SCAN_BUILD} ./configure"
|
CONFIGURE: "${SCAN_BUILD} ./configure"
|
||||||
EXTRA_CONFIGURE: "--enable-dnstap --with-libidn2"
|
EXTRA_CONFIGURE: "--enable-dnstap --with-libidn2"
|
||||||
@@ -878,7 +886,7 @@ tsan:buster:amd64:
|
|||||||
<<: *debian_buster_amd64_image
|
<<: *debian_buster_amd64_image
|
||||||
<<: *build_job
|
<<: *build_job
|
||||||
variables:
|
variables:
|
||||||
CC: clang-9
|
CC: "${CLANG}"
|
||||||
CFLAGS: "${CFLAGS_COMMON} -fsanitize=thread -DISC_MEM_USE_INTERNAL_MALLOC=0"
|
CFLAGS: "${CFLAGS_COMMON} -fsanitize=thread -DISC_MEM_USE_INTERNAL_MALLOC=0"
|
||||||
LDFLAGS: "-fsanitize=thread"
|
LDFLAGS: "-fsanitize=thread"
|
||||||
EXTRA_CONFIGURE: "--with-libidn2 --enable-pthread-rwlock"
|
EXTRA_CONFIGURE: "--with-libidn2 --enable-pthread-rwlock"
|
||||||
|
|||||||
Regular → Executable
+14
-6
@@ -9,19 +9,27 @@
|
|||||||
# See the COPYRIGHT file distributed with this work for additional
|
# See the COPYRIGHT file distributed with this work for additional
|
||||||
# information regarding copyright ownership.
|
# information regarding copyright ownership.
|
||||||
|
|
||||||
|
CLANG_FORMAT=clang-format
|
||||||
|
if [ -n "$1" ]; then
|
||||||
|
CLANG_FORMAT="$1"
|
||||||
|
fi
|
||||||
|
|
||||||
|
CLANG_FORMAT_VERSION=$("$CLANG_FORMAT" --version | sed -e 's/clang-format version \([0-9]*\)\..*/\1/')
|
||||||
|
|
||||||
|
if [ "$CLANG_FORMAT_VERSION" -lt 11 ]; then
|
||||||
|
echo "clang-format version 11 required"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
# use the main .clang-format for C files
|
# use the main .clang-format for C files
|
||||||
find bin lib -name "*.c" |
|
"$CLANG_FORMAT" --style=file --sort-includes -i $(git ls-files '*.c')
|
||||||
xargs clang-format --style=file --sort-includes -i
|
|
||||||
|
|
||||||
# set up a temporary .clang-format file for headers ONLY
|
# set up a temporary .clang-format file for headers ONLY
|
||||||
cp -f .clang-format .clang-format.bak
|
cp -f .clang-format .clang-format.bak
|
||||||
sed -e 's/\(AlignConsecutiveDeclarations\).*/\1: true/' \
|
sed -e 's/\(AlignConsecutiveDeclarations\).*/\1: true/' \
|
||||||
-e 's/\(AlwaysBreakAfterReturnType\).*/\1: All/' \
|
|
||||||
.clang-format.bak > .clang-format
|
.clang-format.bak > .clang-format
|
||||||
|
|
||||||
# modify header files
|
"$CLANG_FORMAT" --style=file --sort-includes -i $(git ls-files '*.h')
|
||||||
find bin lib -name "*.h" |
|
|
||||||
xargs clang-format --style=file --sort-includes -i
|
|
||||||
|
|
||||||
# restore the original .clang-format file
|
# restore the original .clang-format file
|
||||||
cp -f .clang-format.bak .clang-format
|
cp -f .clang-format.bak .clang-format
|
||||||
|
|||||||
Reference in New Issue
Block a user