aboutsummaryrefslogtreecommitdiff
path: root/Tools/check_code_style.sh
diff options
context:
space:
mode:
authorDaniel Agar <daniel@agar.ca>2015-01-05 23:16:30 -0500
committerDaniel Agar <daniel@agar.ca>2015-03-02 12:48:19 -0500
commitb1dcb10f25862d7d833d91518a007b618236ad64 (patch)
tree267ece5eabff3b7ec7b7c77455259dab3a94a149 /Tools/check_code_style.sh
parent0cd5fa2d1d6f388569ccb290cc895459430d7e75 (diff)
downloadpx4-firmware-b1dcb10f25862d7d833d91518a007b618236ad64.tar.gz
px4-firmware-b1dcb10f25862d7d833d91518a007b618236ad64.tar.bz2
px4-firmware-b1dcb10f25862d7d833d91518a007b618236ad64.zip
add make check_format to check astyle code formatting
Diffstat (limited to 'Tools/check_code_style.sh')
-rwxr-xr-xTools/check_code_style.sh28
1 files changed, 28 insertions, 0 deletions
diff --git a/Tools/check_code_style.sh b/Tools/check_code_style.sh
new file mode 100755
index 000000000..491fbb0ce
--- /dev/null
+++ b/Tools/check_code_style.sh
@@ -0,0 +1,28 @@
+#!/usr/bin/env bash
+set -eu
+failed=0
+for fn in $(find . -path './src/lib/uavcan' -prune -o \
+ -path './NuttX' -prune -o \
+ -path './Build' -prune -o \
+ -path './mavlink' -prune -o \
+ -path './unittests/gtest' -prune -o \
+ -name '*.c' -o -name '*.cpp' -o -name '*.hpp' -o -name '*.h' -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 $diffsize $fn
+ fi
+ fi
+done
+
+if [ $failed -eq 0 ]; then
+ echo "Format checks passed"
+ exit 0
+else
+ echo "Format checks failed; please run ./Tools/fix_code_style.sh on each file"
+ exit 1
+fi