1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
|
#!/bin/sh
set -eu
SCRIPT_DIR=$(dirname "$0")
case $SCRIPT_DIR in
"/"*)
;;
".")
SCRIPT_DIR=$(pwd)
;;
*)
SCRIPT_DIR=$(pwd)/$(dirname "$0")
;;
esac
TOPDIR="$(readlink -f $SCRIPT_DIR/..)"
if ! (clang-format-15 --version 2>/dev/null); then
echo "clang-format 15 not available. Running it from a Docker image";
docker pull silkeh/clang:15-bullseye
UID=$(id -u "${USER}")
GID=$(id -g "${USER}")
exec docker run --rm -u "$UID:$GID" -v "$TOPDIR":"$TOPDIR" silkeh/clang:15-bullseye "$TOPDIR"/scripts/reformat_cpp.sh
fi
for i in `find "$TOPDIR" -name "*.h" -o -name "*.hpp" -o -name "*.cpp" -o -name "*.c"`; do
if echo "$i" | grep -q "lru_cache.hpp"; then
continue
fi
if echo "$i" | grep -q "json.hpp"; then
continue
fi
if echo "$i" | grep -q "generated"; then
continue
fi
if echo "$i" | grep -q "geodesic"; then
continue
fi
if echo "$i" | grep -q "geodtest"; then
continue
fi
if echo "$i" | grep -q "geodsigntest"; then
continue
fi
if echo "$i" | grep -q "nn.hpp"; then
continue
fi
if echo "$i" | grep -q "googletest-src"; then
continue
fi
if echo "$i" | grep -q "/build"; then
continue
fi
if echo "$i" | grep -q "fix_typos"; then
continue
fi
echo "reformat.sh $i"
"$SCRIPT_DIR"/reformat.sh "$i"
done
|