From 654927c871bd99b2f318a32b8cf60195927333f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= Date: Fri, 14 Feb 2020 09:14:28 +0100 Subject: [PATCH] Add separate .clang-format files for headers --- .clang-format.headers | 61 +++++++++++++++++++++++ .gitlab-ci.yml | 2 +- bin/confgen/include/.clang-format | 1 + bin/dig/include/.clang-format | 1 + bin/named/include/.clang-format | 1 + bin/named/unix/include/.clang-format | 1 + bin/named/win32/include/.clang-format | 1 + bin/rndc/include/.clang-format | 1 + contrib/dlz/drivers/include/.clang-format | 1 + contrib/dlz/modules/include/.clang-format | 1 + lib/bind9/include/.clang-format | 1 + lib/dns/include/.clang-format | 1 + lib/irs/include/.clang-format | 1 + lib/irs/win32/include/.clang-format | 1 + lib/isc/include/.clang-format | 1 + lib/isc/pthreads/include/.clang-format | 1 + lib/isc/unix/include/.clang-format | 1 + lib/isc/win32/include/.clang-format | 1 + lib/isccc/include/.clang-format | 1 + lib/isccfg/include/.clang-format | 1 + lib/ns/include/.clang-format | 1 + util/cformat.sh | 36 ------------- 22 files changed, 81 insertions(+), 37 deletions(-) create mode 100644 .clang-format.headers create mode 120000 bin/confgen/include/.clang-format create mode 120000 bin/dig/include/.clang-format create mode 120000 bin/named/include/.clang-format create mode 120000 bin/named/unix/include/.clang-format create mode 120000 bin/named/win32/include/.clang-format create mode 120000 bin/rndc/include/.clang-format create mode 120000 contrib/dlz/drivers/include/.clang-format create mode 120000 contrib/dlz/modules/include/.clang-format create mode 120000 lib/bind9/include/.clang-format create mode 120000 lib/dns/include/.clang-format create mode 120000 lib/irs/include/.clang-format create mode 120000 lib/irs/win32/include/.clang-format create mode 120000 lib/isc/include/.clang-format create mode 120000 lib/isc/pthreads/include/.clang-format create mode 120000 lib/isc/unix/include/.clang-format create mode 120000 lib/isc/win32/include/.clang-format create mode 120000 lib/isccc/include/.clang-format create mode 120000 lib/isccfg/include/.clang-format create mode 120000 lib/ns/include/.clang-format delete mode 100755 util/cformat.sh diff --git a/.clang-format.headers b/.clang-format.headers new file mode 100644 index 0000000000..0e36bb427b --- /dev/null +++ b/.clang-format.headers @@ -0,0 +1,61 @@ +BasedOnStyle: LLVM +IndentWidth: 8 +UseTab: Always +BreakBeforeBraces: Custom +BraceWrapping: + AfterClass: false + AfterEnum: false + AfterStruct: false + AfterUnion: false + AfterControlStatement: MultiLine + AfterFunction: false # should also be MultiLine, but not yet supported + AfterExternBlock: false + BeforeElse: false + IndentBraces: false + SplitEmptyFunction: true +AllowShortIfStatementsOnASingleLine: false +IndentCaseLabels: false +AlwaysBreakAfterReturnType: All +Cpp11BracedListStyle: false +ColumnLimit: 80 +AlignAfterOpenBracket: Align +AlignConsecutiveDeclarations: true +AlignConsecutiveMacros: true +AlignTrailingComments: true +AllowAllArgumentsOnNextLine: true +AlwaysBreakBeforeMultilineStrings: false +BreakBeforeBinaryOperators: None +BreakBeforeTernaryOperators: true +AlignEscapedNewlines: Left +DerivePointerAlignment: false +PointerAlignment: Right +PointerBindsToType: false +IncludeBlocks: Regroup +IncludeCategories: + - Regex: '^' + Priority: 1 + - Regex: '".*"' + Priority: 9 +KeepEmptyLinesAtTheStartOfBlocks: false +MaxEmptyLinesToKeep: 1 +PenaltyBreakAssignment: 30 +PenaltyBreakComment: 10 +PenaltyBreakFirstLessLess: 0 +PenaltyBreakString: 10 +PenaltyExcessCharacter: 100 +Standard: Cpp11 +ContinuationIndentWidth: 8 diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 7719ea14a7..9ce010ff21 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -389,7 +389,7 @@ misc:sid:amd64: 💾:sid:amd64: <<: *precheck_job script: - - if [ -r .clang-format ]; then ./util/cformat.sh "${CLANG_FORMAT}"; fi + - if [ -r .clang-format ]; then "${CLANG_FORMAT}" -i -style=file $(git ls-files '*.c' '*.h'); fi - if test "$(git status --porcelain | grep -Ev '\?\?' | wc -l)" -gt "0"; then git status --short; exit 1; fi 🐞:sid:amd64: diff --git a/bin/confgen/include/.clang-format b/bin/confgen/include/.clang-format new file mode 120000 index 0000000000..0e62f72bcf --- /dev/null +++ b/bin/confgen/include/.clang-format @@ -0,0 +1 @@ +../../../.clang-format.headers \ No newline at end of file diff --git a/bin/dig/include/.clang-format b/bin/dig/include/.clang-format new file mode 120000 index 0000000000..0e62f72bcf --- /dev/null +++ b/bin/dig/include/.clang-format @@ -0,0 +1 @@ +../../../.clang-format.headers \ No newline at end of file diff --git a/bin/named/include/.clang-format b/bin/named/include/.clang-format new file mode 120000 index 0000000000..0e62f72bcf --- /dev/null +++ b/bin/named/include/.clang-format @@ -0,0 +1 @@ +../../../.clang-format.headers \ No newline at end of file diff --git a/bin/named/unix/include/.clang-format b/bin/named/unix/include/.clang-format new file mode 120000 index 0000000000..0e62f72bcf --- /dev/null +++ b/bin/named/unix/include/.clang-format @@ -0,0 +1 @@ +../../../.clang-format.headers \ No newline at end of file diff --git a/bin/named/win32/include/.clang-format b/bin/named/win32/include/.clang-format new file mode 120000 index 0000000000..0e62f72bcf --- /dev/null +++ b/bin/named/win32/include/.clang-format @@ -0,0 +1 @@ +../../../.clang-format.headers \ No newline at end of file diff --git a/bin/rndc/include/.clang-format b/bin/rndc/include/.clang-format new file mode 120000 index 0000000000..0e62f72bcf --- /dev/null +++ b/bin/rndc/include/.clang-format @@ -0,0 +1 @@ +../../../.clang-format.headers \ No newline at end of file diff --git a/contrib/dlz/drivers/include/.clang-format b/contrib/dlz/drivers/include/.clang-format new file mode 120000 index 0000000000..0e62f72bcf --- /dev/null +++ b/contrib/dlz/drivers/include/.clang-format @@ -0,0 +1 @@ +../../../.clang-format.headers \ No newline at end of file diff --git a/contrib/dlz/modules/include/.clang-format b/contrib/dlz/modules/include/.clang-format new file mode 120000 index 0000000000..0e62f72bcf --- /dev/null +++ b/contrib/dlz/modules/include/.clang-format @@ -0,0 +1 @@ +../../../.clang-format.headers \ No newline at end of file diff --git a/lib/bind9/include/.clang-format b/lib/bind9/include/.clang-format new file mode 120000 index 0000000000..0e62f72bcf --- /dev/null +++ b/lib/bind9/include/.clang-format @@ -0,0 +1 @@ +../../../.clang-format.headers \ No newline at end of file diff --git a/lib/dns/include/.clang-format b/lib/dns/include/.clang-format new file mode 120000 index 0000000000..0e62f72bcf --- /dev/null +++ b/lib/dns/include/.clang-format @@ -0,0 +1 @@ +../../../.clang-format.headers \ No newline at end of file diff --git a/lib/irs/include/.clang-format b/lib/irs/include/.clang-format new file mode 120000 index 0000000000..0e62f72bcf --- /dev/null +++ b/lib/irs/include/.clang-format @@ -0,0 +1 @@ +../../../.clang-format.headers \ No newline at end of file diff --git a/lib/irs/win32/include/.clang-format b/lib/irs/win32/include/.clang-format new file mode 120000 index 0000000000..0e62f72bcf --- /dev/null +++ b/lib/irs/win32/include/.clang-format @@ -0,0 +1 @@ +../../../.clang-format.headers \ No newline at end of file diff --git a/lib/isc/include/.clang-format b/lib/isc/include/.clang-format new file mode 120000 index 0000000000..0e62f72bcf --- /dev/null +++ b/lib/isc/include/.clang-format @@ -0,0 +1 @@ +../../../.clang-format.headers \ No newline at end of file diff --git a/lib/isc/pthreads/include/.clang-format b/lib/isc/pthreads/include/.clang-format new file mode 120000 index 0000000000..0e62f72bcf --- /dev/null +++ b/lib/isc/pthreads/include/.clang-format @@ -0,0 +1 @@ +../../../.clang-format.headers \ No newline at end of file diff --git a/lib/isc/unix/include/.clang-format b/lib/isc/unix/include/.clang-format new file mode 120000 index 0000000000..0e62f72bcf --- /dev/null +++ b/lib/isc/unix/include/.clang-format @@ -0,0 +1 @@ +../../../.clang-format.headers \ No newline at end of file diff --git a/lib/isc/win32/include/.clang-format b/lib/isc/win32/include/.clang-format new file mode 120000 index 0000000000..0e62f72bcf --- /dev/null +++ b/lib/isc/win32/include/.clang-format @@ -0,0 +1 @@ +../../../.clang-format.headers \ No newline at end of file diff --git a/lib/isccc/include/.clang-format b/lib/isccc/include/.clang-format new file mode 120000 index 0000000000..0e62f72bcf --- /dev/null +++ b/lib/isccc/include/.clang-format @@ -0,0 +1 @@ +../../../.clang-format.headers \ No newline at end of file diff --git a/lib/isccfg/include/.clang-format b/lib/isccfg/include/.clang-format new file mode 120000 index 0000000000..0e62f72bcf --- /dev/null +++ b/lib/isccfg/include/.clang-format @@ -0,0 +1 @@ +../../../.clang-format.headers \ No newline at end of file diff --git a/lib/ns/include/.clang-format b/lib/ns/include/.clang-format new file mode 120000 index 0000000000..0e62f72bcf --- /dev/null +++ b/lib/ns/include/.clang-format @@ -0,0 +1 @@ +../../../.clang-format.headers \ No newline at end of file diff --git a/util/cformat.sh b/util/cformat.sh deleted file mode 100755 index 3ad62318af..0000000000 --- a/util/cformat.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/sh -# -# Copyright (C) Internet Systems Consortium, Inc. ("ISC") -# -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. -# -# See the COPYRIGHT file distributed with this work for additional -# 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 -"$CLANG_FORMAT" --style=file --sort-includes -i $(git ls-files '*.c') - -# set up a temporary .clang-format file for headers ONLY -cp -f .clang-format .clang-format.bak -sed -e 's/\(AlignConsecutiveDeclarations\).*/\1: true/' \ - .clang-format.bak > .clang-format - -"$CLANG_FORMAT" --style=file --sort-includes -i $(git ls-files '*.h') - -# restore the original .clang-format file -cp -f .clang-format.bak .clang-format -rm -f .clang-format.bak