check code style parallel

This commit is contained in:
Daniel Agar 2016-04-21 17:29:49 -04:00 committed by Lorenz Meier
parent 770c6b3bd1
commit 875dbb92e5
3 changed files with 66 additions and 67 deletions

View File

@ -227,7 +227,7 @@ check: check_px4fmu-v1_default check_px4fmu-v2_default check_px4fmu-v2_ekf2 chec
check_format: check_format:
$(call colorecho,"Checking formatting with astyle") $(call colorecho,"Checking formatting with astyle")
@./Tools/fix_code_style.sh @./Tools/fix_code_style.sh
@./Tools/check_code_style.sh @./Tools/check_code_style_all.sh
check_%: check_%:
@echo @echo

View File

@ -1,70 +1,17 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -eu
failed=0
for fn in $(find src/examples \
src/systemcmds \
src/include \
src/drivers \
src/platforms \
src/firmware \
src/lib/launchdetection \
src/lib/geo \
src/lib/geo_lookup \
src/lib/conversion \
src/lib/rc \
src/lib/version \
src/modules/attitude_estimator_q \
src/modules/fw_att_control \
src/modules/gpio_led \
src/modules/land_detector \
src/modules/muorb \
src/modules/px4iofirmware \
src/modules/param \
src/modules/sensors \
src/modules/simulator \
src/modules/uORB \
src/modules/bottle_drop \
src/modules/dataman \
src/modules/segway \
src/modules/local_position_estimator \
src/modules/unit_test \
src/modules/systemlib \
src/lib/controllib \
-path './Build' -prune -o \
-path './mavlink' -prune -o \
-path './NuttX' -prune -o \
-path './src/lib/eigen' -prune -o \
-path './src/modules/uavcan/libuavcan' -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*' \
-not -name '*uthash.h' \
-not -name '*utstring.h' \
-not -name '*utlist.h' \
-not -name '*utarray.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 $fn 'bad formatting, please run "./Tools/fix_code_style.sh' $fn'"'
fi
fi
done
if [ $failed -eq 0 ]; then file=$1
echo "Format checks passed"
exit 0 DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
else
echo "Format checks failed" if [ -f "$file" ];
then
${DIR}/fix_code_style.sh --quiet < $file > $file.pretty
diffsize=$(diff -y --suppress-common-lines $file $file.pretty | wc -l)
rm -f $file.pretty
if [ $diffsize -ne 0 ]; then
echo $file 'bad formatting, please run "./Tools/fix_code_style.sh' $file'"'
exit 1 exit 1
fi
fi fi

52
Tools/check_code_style_all.sh Executable file
View File

@ -0,0 +1,52 @@
#!/usr/bin/env bash
set -eu
failed=0
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
find \
src/drivers \
src/examples \
src/firmware \
src/include \
src/lib/controllib \
src/lib/conversion \
src/lib/geo \
src/lib/geo_lookup \
src/lib/launchdetection \
src/lib/rc \
src/lib/tailsitter_recovery \
src/lib/terrain_estimation \
src/lib/version \
src/modules/attitude_estimator_q \
src/modules/bottle_drop \
src/modules/controllib_test \
src/modules/dataman \
src/modules/fw_att_control \
src/modules/gpio_led \
src/modules/land_detector \
src/modules/local_position_estimator \
src/modules/muorb \
src/modules/param \
src/modules/px4iofirmware \
src/modules/segway \
src/modules/sensors \
src/modules/simulator \
src/modules/systemlib \
src/modules/unit_test \
src/modules/uORB \
src/platforms \
src/systemcmds \
-type f \( -name "*.c" -o -name "*.h" -o -name "*.cpp" -o -name "*.hpp" \) \
-not -name '*generated.h' \
-not -name '*uthash.h' \
-not -name '*utstring.h' \
-not -name '*utlist.h' \
-not -name '*utarray.h' \
-print0 | xargs -0 -n 1 -P 8 -I % ${DIR}/check_code_style.sh %
if [ $? -eq 0 ]; then
echo "Format checks passed"
exit 0
fi