diff --git a/Makefile b/Makefile index bf399d19bf..3c47aad3e0 100644 --- a/Makefile +++ b/Makefile @@ -222,9 +222,9 @@ qurtrun: tests: generateuorbtopicheaders $(Q) (mkdir -p $(PX4_BASE)/unittests/build && cd $(PX4_BASE)/unittests/build && cmake .. && $(MAKE) --no-print-directory unittests) -.PHONY: format check_format +.PHONY: check_format check_format: - $(Q) (./Tools/check_code_style.sh | sort -n) + $(Q) (./Tools/check_code_style.sh) # # Cleanup targets. 'clean' should remove all built products and force diff --git a/Tools/check_code_style.sh b/Tools/check_code_style.sh index b8806f3164..87e9e4f232 100755 --- a/Tools/check_code_style.sh +++ b/Tools/check_code_style.sh @@ -1,16 +1,20 @@ #!/usr/bin/env bash set -eu failed=0 -for fn in $(find . -path './src/lib/uavcan' -prune -o \ - -path './src/lib/mathlib/CMSIS' -prune -o \ - -path './src/lib/eigen' -prune -o \ - -path './src/modules/attitude_estimator_ekf/codegen' -prune -o \ - -path './NuttX' -prune -o \ - -path './Build' -prune -o \ +for fn in $(find . -path './Build' -prune -o \ -path './mavlink' -prune -o \ - -path './unittests/gtest' -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 \ - -name '*.c' -o -name '*.cpp' -o -name '*.hpp' -o -name '*.h' -type f); do + -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 @@ -18,7 +22,7 @@ for fn in $(find . -path './src/lib/uavcan' -prune -o \ rm -f $fn.pretty if [ $diffsize -ne 0 ]; then failed=1 - echo $diffsize $fn + echo $fn 'bad formatting, please run "./Tools/fix_code_style.sh' $fn'"' fi fi done @@ -27,6 +31,6 @@ 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" + echo "Format checks failed" exit 1 fi