mirror of
https://github.com/qpdf/qpdf.git
synced 2024-11-10 23:20:58 +00:00
Use version-specific clang-format if available
This commit is contained in:
parent
a3b939ce58
commit
d96f74ae34
11
format-code
11
format-code
@ -25,18 +25,23 @@
|
|||||||
# that refers to this comment. See also .clang-format.
|
# that refers to this comment. See also .clang-format.
|
||||||
min_version=18
|
min_version=18
|
||||||
|
|
||||||
clang_version=$(clang-format --version | \
|
clang_format=clang-format
|
||||||
|
if clang-format-$min_version --version >/dev/null 2>&1; then
|
||||||
|
clang_format=clang-format-$min_version
|
||||||
|
else
|
||||||
|
clang_version=$(clang-format --version | \
|
||||||
awk '{for (i=1; i<=NF; i++) if ($i == "version") {print int($(i+1)); exit}}')
|
awk '{for (i=1; i<=NF; i++) if ($i == "version") {print int($(i+1)); exit}}')
|
||||||
if [ "$clang_version" -lt "$min_version" ]; then
|
if [ "$clang_version" -lt "$min_version" ]; then
|
||||||
echo "clang-format version >= $min_version is required"
|
echo "clang-format version >= $min_version is required"
|
||||||
exit 2
|
exit 2
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cd $(dirname $0)
|
cd $(dirname $0)
|
||||||
for i in $(find . -name 'build*' -prune -o '(' \
|
for i in $(find . -name 'build*' -prune -o '(' \
|
||||||
-name '*.hh' -o -name '*.h' -o -name '*.cc' -o -name '*.c' \
|
-name '*.hh' -o -name '*.h' -o -name '*.cc' -o -name '*.c' \
|
||||||
')' -print); do
|
')' -print); do
|
||||||
if clang-format < $i >| $i.new; then
|
if $clang_format < $i >| $i.new; then
|
||||||
if diff -q $i $i.new >/dev/null 2>/dev/null; then
|
if diff -q $i $i.new >/dev/null 2>/dev/null; then
|
||||||
echo "okay: $i"
|
echo "okay: $i"
|
||||||
rm $i.new
|
rm $i.new
|
||||||
|
Loading…
Reference in New Issue
Block a user