From b1dcb10f25862d7d833d91518a007b618236ad64 Mon Sep 17 00:00:00 2001 From: Daniel Agar Date: Mon, 5 Jan 2015 23:16:30 -0500 Subject: add make check_format to check astyle code formatting --- Tools/check_code_style.sh | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100755 Tools/check_code_style.sh (limited to 'Tools/check_code_style.sh') 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 -- cgit v1.2.3