mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-21 05:33:35 +08:00
Auto Formatting with clang-format-6.0 (#727)
* Add clang-format * Auto-format AlphaFilter and RingBuffer * Update to tab=8spaces * Allow for 120 width
This commit is contained in:
Executable
+34
@@ -0,0 +1,34 @@
|
||||
#!/bin/bash
|
||||
do_format=$1
|
||||
files_to_format="""
|
||||
EKF/AlphaFilter.hpp
|
||||
EKF/RingBuffer.h
|
||||
"""
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
if ! hash clang-format-6.0
|
||||
then
|
||||
echo -e ${RED}Error: No clang-format-6.0 installed${NC}
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ $do_format -eq 1 ]]
|
||||
then
|
||||
# formatting
|
||||
clang-format-6.0 -i -style=file ${files_to_format}
|
||||
echo -e ${GREEN}Formatting finished${NC}
|
||||
else
|
||||
# checking format...
|
||||
clang-format-6.0 -style=file -output-replacements-xml ${files_to_format} | grep -c "<replacement " > /dev/null
|
||||
if [[ $? -eq 0 ]]
|
||||
then
|
||||
echo -e ${RED}Error: need to format${NC}
|
||||
echo -e ${YELLOW}From cmake build directory run: 'make format'${NC}
|
||||
exit 1
|
||||
fi
|
||||
echo -e ${GREEN}no formatting needed${NC}
|
||||
exit 0
|
||||
fi
|
||||
Reference in New Issue
Block a user