mirror of https://github.com/cutefishos/calamares
CI: use both tools for code-formatting
- astyle can do some things that clang-format doesn't (e.g. adding brackets; you need clang-tidy for that), - clang-format does a much nicer job with lambdas and certain other constructions, - allow passing in directories at a time for formatting.main
parent
54c3adb466
commit
8053bf6f3a
@ -1,6 +1,42 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
#
|
||||||
# Calls astyle with settings matching Calamares coding style
|
# Calls astyle with settings matching Calamares coding style
|
||||||
# Requires astyle >= 2.04
|
# Requires astyle >= 2.04 and clang-format-7
|
||||||
|
#
|
||||||
|
# You can pass in directory names, in which case the files
|
||||||
|
# in that directory (NOT below it) are processed.
|
||||||
|
#
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
astyle --options=$(dirname $0)/astylerc "$@"
|
AS=$( which astyle )
|
||||||
|
CF=$( which clang-format-7 )
|
||||||
|
|
||||||
|
test -n "$AS" || { echo "! No astyle found in PATH"; exit 1 ; }
|
||||||
|
test -n "$CF" || { echo "! No clang-format-7 found in PATH"; exit 1 ; }
|
||||||
|
test -x "$AS" || { echo "! $AS is not executable."; exit 1 ; }
|
||||||
|
test -x "$CF" || { echo "! $CF is not executable."; exit 1 ; }
|
||||||
|
|
||||||
|
any_dirs=no
|
||||||
|
for d in "$@"
|
||||||
|
do
|
||||||
|
test -d "$d" && any_dirs=yes
|
||||||
|
done
|
||||||
|
|
||||||
|
style_some()
|
||||||
|
{
|
||||||
|
$AS --options=$(dirname $0)/astylerc --quiet "$@"
|
||||||
|
$CF -i -style=file "$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
if test "x$any_dirs" = "xyes" ; then
|
||||||
|
for d in "$@"
|
||||||
|
do
|
||||||
|
if test -d "$@" ; then
|
||||||
|
style_some $( find "$d" -maxdepth 1 -type f -name '*.cpp' -o -name '*.h' )
|
||||||
|
else
|
||||||
|
style_some "$d"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
else
|
||||||
|
style_some "$@"
|
||||||
|
fi
|
||||||
|
Loading…
Reference in New Issue