mirror of
https://gitlab.isc.org/isc-projects/kea
synced 2025-08-22 01:49:48 +00:00
[#1455] clang-format, uncrustify
This commit is contained in:
parent
a31922d3a3
commit
c7311fa52b
100
.clang-format
Normal file
100
.clang-format
Normal file
@ -0,0 +1,100 @@
|
||||
AccessModifierOffset: -4
|
||||
AlignAfterOpenBracket: Align
|
||||
AlignConsecutiveAssignments: false
|
||||
AlignConsecutiveDeclarations: false
|
||||
AlignConsecutiveMacros: true
|
||||
AlignEscapedNewlinesLeft: false
|
||||
AlignEscapedNewlines: Left
|
||||
AlignTrailingComments: true
|
||||
AllowAllArgumentsOnNextLine: true
|
||||
AllowAllParametersOfDeclarationOnNextLine: true
|
||||
AllowShortBlocksOnASingleLine: false
|
||||
AllowShortCaseLabelsOnASingleLine: false
|
||||
AllowShortFunctionsOnASingleLine: None
|
||||
AllowShortIfStatementsOnASingleLine: false
|
||||
AllowShortLoopsOnASingleLine: false
|
||||
AlwaysBreakAfterReturnType: TopLevel
|
||||
AlwaysBreakBeforeMultilineStrings: false
|
||||
AlwaysBreakTemplateDeclarations: true
|
||||
BasedOnStyle: LLVM
|
||||
BinPackArguments: true
|
||||
BinPackParameters: false
|
||||
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
|
||||
BreakBeforeBinaryOperators: None
|
||||
BreakBeforeBraces: Attach
|
||||
BreakBeforeTernaryOperators: false
|
||||
BreakConstructorInitializersBeforeComma: false
|
||||
ColumnLimit: 100
|
||||
ConstructorInitializerAllOnOneLineOrOnePerLine: false
|
||||
ConstructorInitializerIndentWidth: 4
|
||||
ContinuationIndentWidth: 4
|
||||
Cpp11BracedListStyle: true
|
||||
DerivePointerAlignment: false
|
||||
DerivePointerBinding: true
|
||||
DisableFormat: false
|
||||
ExperimentalAutoDetectBinPacking: false
|
||||
ForEachMacros: [ BOOST_FOREACH ]
|
||||
IncludeBlocks: Regroup
|
||||
IncludeCategories:
|
||||
# config.h first thing
|
||||
- Regex: '^<config.h>$'
|
||||
Priority: 0
|
||||
# Kea's own files
|
||||
- Regex: '^<(asiodns|asiolink|cc|cfgrpt|config|config_backend|cql|cryptolink|database|dhcp|dhcpsrv|dhcp_ddns|dns|eval|exceptions|hooks|http|log|mysql|pgsql|process|stats|testutils|util|yang|admin|agent|d2|dhcp4|dhcp6|keactrl|lfc|netconf|perfdhcp|shell)/'
|
||||
Priority: 1
|
||||
# C++ standard library headers
|
||||
- Regex: '^<[[:alnum:]]>$'
|
||||
Priority: 2
|
||||
# boost headers
|
||||
- Regex: '^<boost/'
|
||||
Priority: 3
|
||||
# C headers
|
||||
- Regex: '^<[[:alnum:]].h>$'
|
||||
Priority: 4
|
||||
# everything else
|
||||
- Regex: '.*'
|
||||
Priority: 5
|
||||
IndentCaseLabels: false
|
||||
IndentFunctionDeclarationAfterType: false
|
||||
IndentWidth: 4
|
||||
IndentWrappedFunctionNames: false
|
||||
KeepEmptyLinesAtTheStartOfBlocks: false
|
||||
KeepEmptyLinesAtTheStartOfBlocks: true
|
||||
Language: Cpp
|
||||
MaxEmptyLinesToKeep: 1
|
||||
NamespaceIndentation: None
|
||||
PenaltyBreakAssignment: 30
|
||||
PenaltyBreakBeforeFirstCallParameter: 80
|
||||
PenaltyBreakComment: 10
|
||||
PenaltyBreakFirstLessLess: 0
|
||||
PenaltyBreakString: 80
|
||||
PenaltyBreakTemplateDeclaration: 100
|
||||
PenaltyExcessCharacter: 100
|
||||
PenaltyReturnTypeOnItsOwnLine: 0
|
||||
PointerAlignment: Left
|
||||
PointerBindsToType: true
|
||||
ReflowComments: true
|
||||
SortIncludes: true
|
||||
SpaceAfterCStyleCast: false
|
||||
SpaceBeforeAssignmentOperators: true
|
||||
SpaceBeforeParens: ControlStatements
|
||||
SpaceInEmptyParentheses: false
|
||||
SpacesBeforeTrailingComments: 2
|
||||
SpacesInAngles: false
|
||||
SpacesInCStyleCastParentheses: false
|
||||
SpacesInContainerLiterals: false
|
||||
SpacesInParentheses: false
|
||||
SpacesInSquareBrackets: false
|
||||
Standard: Cpp11
|
||||
TabWidth: 4
|
||||
UseTab: Never
|
1429
.uncrustify.cfg
Normal file
1429
.uncrustify.cfg
Normal file
File diff suppressed because it is too large
Load Diff
105
tools/clang-format.sh
Executable file
105
tools/clang-format.sh
Executable file
@ -0,0 +1,105 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Copyright (C) 2020 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/.
|
||||
|
||||
# Usage:
|
||||
#
|
||||
# ./tools/clang-format.sh [-d|--debug] [-h|--help] [$directory|$file ...]
|
||||
#
|
||||
# Run from the root of the repository to format all C++ files under specified
|
||||
# directories or specified files or current directory in case of no arguments.
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
|
||||
set -eu
|
||||
|
||||
# Customizations
|
||||
extensions_regex='(\.cpp|\.cc|\.C|\.cxx|\.m|\.hpp|\.hh|\.h|\.H|\.hxx|\.tpp)$'
|
||||
|
||||
# Print usage.
|
||||
print_usage() {
|
||||
printf \
|
||||
'Usage: %s {{options}}
|
||||
Options:
|
||||
[-d|--debug] enable debug mode, showing every executed command
|
||||
[-h|--help] print usage (this text)
|
||||
' \
|
||||
"$(basename "${0}")"
|
||||
}
|
||||
|
||||
# Parse parameters.
|
||||
while test ${#} -gt 0; do
|
||||
case "${1}" in
|
||||
# [-d|--debug] enable debug mode, showing every executed command
|
||||
'-d'|'--debug') set -vx ;;
|
||||
|
||||
# [-h|--help] print usage (this text).
|
||||
'-h'|'--help') print_usage ;;
|
||||
|
||||
# Allow extra arguments, they should be directories or files to be formatted.
|
||||
*) break ;;
|
||||
esac; shift
|
||||
done
|
||||
|
||||
# Get script path.
|
||||
script_path=$(cd "$(dirname "${0}")" && pwd)
|
||||
|
||||
# Use current directory when called without an argument.
|
||||
if test ${#} = 0; then
|
||||
set -- .
|
||||
fi
|
||||
|
||||
# Generated files will be filtered out.
|
||||
filtered_out=$("${script_path}/print-generated-files.sh")
|
||||
|
||||
# For all arguments...
|
||||
parameters=
|
||||
while test ${#} -gt 0; do
|
||||
# Preserve parameters that begin with dash and pass them to clang-format.
|
||||
if test "$(printf '%s' "${1}" | cut -c 1)" = '-'; then
|
||||
parameters="${parameters} ${1}"
|
||||
shift
|
||||
continue
|
||||
fi
|
||||
|
||||
# The rest of the parameters are considered files or directories.
|
||||
file=${1}
|
||||
|
||||
# Get absolute path.
|
||||
if test "$(printf '%s' "${file}" | grep -Eo '^.')" != '/'; then
|
||||
basename=$(basename "${file}")
|
||||
if test "${basename}" = .; then
|
||||
basename=
|
||||
fi
|
||||
file="$(cd "$(dirname "${file}")" && pwd)/${basename}"
|
||||
fi
|
||||
printf '%s\n' "${file}"
|
||||
|
||||
if test -f "${file}"; then
|
||||
# Format file.
|
||||
# shellcheck disable=SC2046
|
||||
# We specifically want word splitting for the parameters.
|
||||
clang-format --style=file -i $(printf '%s' "${parameters}") "${file}"
|
||||
elif test -d "${file}"; then
|
||||
# Get list of files to format.
|
||||
cd "$(git rev-parse --show-toplevel)"
|
||||
files=$(git ls-files | xargs -n1 printf "${PWD}/%s\\n" | grep -F "${file}" \
|
||||
| grep -E "${extensions_regex}")
|
||||
|
||||
# Filter out generated files.
|
||||
for file in ${filtered_out}; do
|
||||
files=$(printf '%s\n' "${files}" | grep -Fv "${file}" | sed '/^$/d')
|
||||
done
|
||||
|
||||
# For all files...
|
||||
for i in ${files}; do
|
||||
"${0}" "${i}"
|
||||
done
|
||||
fi
|
||||
|
||||
shift
|
||||
done
|
105
tools/uncrustify.sh
Executable file
105
tools/uncrustify.sh
Executable file
@ -0,0 +1,105 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Copyright (C) 2020 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/.
|
||||
|
||||
# Usage:
|
||||
#
|
||||
# ./tools/uncrustify.sh [-d|--debug] [-h|--help] [$directory|$file ...]
|
||||
#
|
||||
# Run from the root of the repository to format all C++ files under specified
|
||||
# directories or specified files or current directory in case of no arguments.
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
|
||||
set -eu
|
||||
|
||||
# Customizations
|
||||
extensions_regex='(\.cpp|\.cc|\.C|\.cxx|\.m|\.hpp|\.hh|\.h|\.H|\.hxx|\.tpp)$'
|
||||
|
||||
# Print usage.
|
||||
print_usage() {
|
||||
printf \
|
||||
'Usage: %s {{options}}
|
||||
Options:
|
||||
[-d|--debug] enable debug mode, showing every executed command
|
||||
[-h|--help] print usage (this text)
|
||||
' \
|
||||
"$(basename "${0}")"
|
||||
}
|
||||
|
||||
# Parse parameters.
|
||||
while test ${#} -gt 0; do
|
||||
case "${1}" in
|
||||
# [-d|--debug] enable debug mode, showing every executed command
|
||||
'-d'|'--debug') set -vx ;;
|
||||
|
||||
# [-h|--help] print usage (this text).
|
||||
'-h'|'--help') print_usage ;;
|
||||
|
||||
# Allow extra arguments, they should be directories or files to be formatted.
|
||||
*) break ;;
|
||||
esac; shift
|
||||
done
|
||||
|
||||
# Get script path.
|
||||
script_path=$(cd "$(dirname "${0}")" && pwd)
|
||||
|
||||
# Use current directory when called without an argument.
|
||||
if test ${#} = 0; then
|
||||
set -- .
|
||||
fi
|
||||
|
||||
# Generated files will be filtered out.
|
||||
filtered_out=$("${script_path}/print-generated-files.sh")
|
||||
|
||||
# For all arguments...
|
||||
parameters=
|
||||
while test ${#} -gt 0; do
|
||||
# Preserve parameters that begin with dash and pass them to uncrustify.
|
||||
if test "$(printf '%s' "${1}" | cut -c 1)" = '-'; then
|
||||
parameters="${parameters} ${1}"
|
||||
shift
|
||||
continue
|
||||
fi
|
||||
|
||||
# The rest of the parameters are considered files or directories.
|
||||
file=${1}
|
||||
|
||||
# Get absolute path.
|
||||
if test "$(printf '%s' "${file}" | grep -Eo '^.')" != '/'; then
|
||||
basename=$(basename "${file}")
|
||||
if test "${basename}" = .; then
|
||||
basename=
|
||||
fi
|
||||
file="$(cd "$(dirname "${file}")" && pwd)/${basename}"
|
||||
fi
|
||||
printf '%s\n' "${file}"
|
||||
|
||||
if test -f "${file}"; then
|
||||
# Format file.
|
||||
# shellcheck disable=SC2046
|
||||
# We specifically want word splitting for the parameters.
|
||||
uncrustify -c "${script_path}/../.uncrustify.cfg" --replace $(printf '%s' "${parameters}") "${file}"
|
||||
elif test -d "${file}"; then
|
||||
# Get list of files to format.
|
||||
cd "$(git rev-parse --show-toplevel)"
|
||||
files=$(git ls-files | xargs -n1 printf "${PWD}/%s\\n" | grep -F "${file}" \
|
||||
| grep -E "${extensions_regex}")
|
||||
|
||||
# Filter out generated files.
|
||||
for file in ${filtered_out}; do
|
||||
files=$(printf '%s\n' "${files}" | grep -Fv "${file}" | sed '/^$/d')
|
||||
done
|
||||
|
||||
# For all files...
|
||||
for i in ${files}; do
|
||||
"${0}" "${i}"
|
||||
done
|
||||
fi
|
||||
|
||||
shift
|
||||
done
|
Loading…
x
Reference in New Issue
Block a user