mirror of
https://github.com/transmission/transmission
synced 2024-12-21 23:32:35 +00:00
Adopting .clang-format-include and .clang-format-ignore (#3047)
This commit is contained in:
parent
5026d43920
commit
7ab2fbfbd6
3 changed files with 43 additions and 19 deletions
22
.clang-format-ignore
Normal file
22
.clang-format-ignore
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
# Skipped files must be justified as untracked or third-party maintained
|
||||||
|
|
||||||
|
# untracked files
|
||||||
|
.*/*
|
||||||
|
build/*
|
||||||
|
libtransmission/version.h
|
||||||
|
web/node_modules/*
|
||||||
|
|
||||||
|
# third-party maintained projects
|
||||||
|
third-party/*
|
||||||
|
|
||||||
|
# maintained at https://github.com/sparkle-project/Sparkle
|
||||||
|
macosx/Sparkle.framework/*
|
||||||
|
|
||||||
|
# maintained at https://github.com/bdkjones/VDKQueue
|
||||||
|
macosx/VDKQueue/*
|
||||||
|
|
||||||
|
# maintained at https://github.com/mnunberg/jsonsl
|
||||||
|
libtransmission/jsonsl.*
|
||||||
|
|
||||||
|
# missing official maintainer (XConsortium: wildmat.c,v 1.2 94/04/13); TODO: clang-format it
|
||||||
|
libtransmission/wildmat.*
|
5
.clang-format-include
Normal file
5
.clang-format-include
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
*.c
|
||||||
|
*.cc
|
||||||
|
*.h
|
||||||
|
*.m
|
||||||
|
*.mm
|
|
@ -5,6 +5,12 @@
|
||||||
|
|
||||||
set -o noglob
|
set -o noglob
|
||||||
|
|
||||||
|
# PATH workaround for SourceTree
|
||||||
|
# for Intel Mac
|
||||||
|
PATH="${PATH}:/usr/local/bin"
|
||||||
|
# for Apple Silicon Mac
|
||||||
|
PATH="${PATH}:/opt/homebrew/bin"
|
||||||
|
|
||||||
if [[ "x$1" == *"check"* ]]; then
|
if [[ "x$1" == *"check"* ]]; then
|
||||||
echo "checking code format"
|
echo "checking code format"
|
||||||
else
|
else
|
||||||
|
@ -15,24 +21,13 @@ root="$(dirname "$0")"
|
||||||
root="$(cd "${root}" && pwd)"
|
root="$(cd "${root}" && pwd)"
|
||||||
cd "${root}" || exit 1
|
cd "${root}" || exit 1
|
||||||
|
|
||||||
cfile_includes=(
|
trim_comments() {
|
||||||
'*.c'
|
# 1. remove comments, ignoring backslash-escaped characters
|
||||||
'*.cc'
|
# 2. trim spaces
|
||||||
'*.h'
|
# 3. remove empty lines
|
||||||
'*.m'
|
# note: GNU extensions like +?| aren't supported on macOS
|
||||||
'*.mm'
|
sed 's/^\(\(\(\\.\)*[^\\#]*\)*\)#.*/\1/;s/^[[:blank:]]*//;s/[[:blank:]]*$//;/^$/d' "$@"
|
||||||
)
|
}
|
||||||
cfile_excludes=(
|
|
||||||
'build/*'
|
|
||||||
'libtransmission/ConvertUTF.*'
|
|
||||||
'libtransmission/jsonsl.*'
|
|
||||||
'libtransmission/wildmat.*'
|
|
||||||
'macosx/Sparkle.framework/*'
|
|
||||||
'macosx/VDKQueue/*'
|
|
||||||
'third-party/*'
|
|
||||||
'web/*'
|
|
||||||
'.git/*'
|
|
||||||
)
|
|
||||||
|
|
||||||
get_find_path_args() {
|
get_find_path_args() {
|
||||||
local args=$(printf " -o -path ./%s" "$@")
|
local args=$(printf " -o -path ./%s" "$@")
|
||||||
|
@ -40,7 +35,9 @@ get_find_path_args() {
|
||||||
}
|
}
|
||||||
|
|
||||||
find_cfiles() {
|
find_cfiles() {
|
||||||
find . \( $(get_find_path_args "${cfile_includes[@]}") \) ! \( $(get_find_path_args "${cfile_excludes[@]}") \) "$@"
|
# We use the same files as Meson: https://mesonbuild.com/Code-formatting.html
|
||||||
|
find . \( $(get_find_path_args $(trim_comments .clang-format-include)) \)\
|
||||||
|
! \( $(get_find_path_args $(trim_comments .clang-format-ignore)) \) "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
# We're targeting clang-format version 12 and other versions give slightly
|
# We're targeting clang-format version 12 and other versions give slightly
|
||||||
|
|
Loading…
Reference in a new issue