px4-firmware/Tools/check_code_style.sh

39 lines
1.4 KiB
Bash
Executable File

#!/usr/bin/env bash
set -eu
failed=0
for fn in $(find src/examples \
src/systemcmds \
-path './Build' -prune -o \
-path './mavlink' -prune -o \
-path './NuttX' -prune -o \
-path './src/lib/eigen' -prune -o \
-path './src/lib/mathlib/CMSIS' -prune -o \
-path './src/lib/uavcan' -prune -o \
-path './src/modules/attitude_estimator_ekf/codegen' -prune -o \
-path './src/modules/ekf_att_pos_estimator' -prune -o \
-path './src/modules/sdlog2' -prune -o \
-path './src/modules/uORB' -prune -o \
-path './src/modules/vtol_att_control' -prune -o \
-path './unittests/build' -prune -o \
-path './unittests/gtest' -prune -o \
-name '*.c' -o -name '*.cpp' -o -name '*.hpp' -o -name '*.h' -not -name '*generated*' -type f); do
if [ -f "$fn" ];
then
./Tools/fix_code_style.sh --quiet < $fn > $fn.pretty
diffsize=$(diff -y --suppress-common-lines $fn $fn.pretty | wc -l)
rm -f $fn.pretty
if [ $diffsize -ne 0 ]; then
failed=1
echo $fn 'bad formatting, please run "./Tools/fix_code_style.sh' $fn'"'
fi
fi
done
if [ $failed -eq 0 ]; then
echo "Format checks passed"
exit 0
else
echo "Format checks failed"
exit 1
fi