mirror of
https://gitee.com/xiaohuolufeihua/bizhang_-obav.git
synced 2026-05-21 01:12:11 +00:00
add make check_format to check astyle code formatting
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -46,3 +46,5 @@ Firmware.zip
|
|||||||
unittests/build
|
unittests/build
|
||||||
*.generated.h
|
*.generated.h
|
||||||
.vagrant
|
.vagrant
|
||||||
|
*.pretty
|
||||||
|
|
||||||
|
|||||||
4
Makefile
4
Makefile
@@ -262,6 +262,10 @@ testbuild:
|
|||||||
tests: generateuorbtopicheaders
|
tests: generateuorbtopicheaders
|
||||||
$(Q) (mkdir -p $(PX4_BASE)/unittests/build && cd $(PX4_BASE)/unittests/build && cmake .. && $(MAKE) unittests)
|
$(Q) (mkdir -p $(PX4_BASE)/unittests/build && cd $(PX4_BASE)/unittests/build && cmake .. && $(MAKE) unittests)
|
||||||
|
|
||||||
|
.PHONY: format check_format
|
||||||
|
check_format:
|
||||||
|
$(Q) (./Tools/check_code_style.sh | sort -n)
|
||||||
|
|
||||||
#
|
#
|
||||||
# Cleanup targets. 'clean' should remove all built products and force
|
# Cleanup targets. 'clean' should remove all built products and force
|
||||||
# a complete re-compilation, 'distclean' should remove everything
|
# a complete re-compilation, 'distclean' should remove everything
|
||||||
|
|||||||
28
Tools/check_code_style.sh
Executable file
28
Tools/check_code_style.sh
Executable file
@@ -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
|
||||||
@@ -18,4 +18,5 @@ astyle \
|
|||||||
--exclude=EASTL \
|
--exclude=EASTL \
|
||||||
--add-brackets \
|
--add-brackets \
|
||||||
--max-code-length=120 \
|
--max-code-length=120 \
|
||||||
|
--preserve-date \
|
||||||
$*
|
$*
|
||||||
|
|||||||
Reference in New Issue
Block a user