-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_check.sh
executable file
·72 lines (58 loc) · 1.79 KB
/
run_check.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/bin/bash
#
# Run C++ code check. Formating and Linting.
#
# - Author: Jongkuk Lim
# - Contact: limjk@jmarple.ai
function run_cmd_on_source() {
run_cmd=$1
exitCode=0
while read -d $'\0' file
do
eval >&2 "$run_cmd $file"
retVal=$?
if [ $retVal -ne 0 ]; then
exitCode=$retVal
fi
done < <(find . -not -path './libs/*' -not -path './examples/config_cli/libs/*' -not -path './build/*' -regex '.*\.\(cpp\|hpp\|h\|cc\|cxx\)' -print0)
echo "$exitCode"
}
CMD_FORMAT="clang-format -verbose -style=file -i"
CMD_LINT="cpplint"
# CMD_DOC_CHECK="( cat Doxyfile ; echo "GENERATE_HTML=NO" ) | doxygen -"
CMD_DOC_CHECK="doxygen -q"
run_cmd=( "$CMD_FORMAT" )
if [ "$1" = "lint" ]; then
run_cmd=( "$CMD_LINT" "cppcheck" )
elif [ "$1" = "format" ]; then
run_cmd=( "$CMD_FORMAT" )
elif [ "$1" = "all" ]; then
run_cmd=( "$CMD_FORMAT" "$CMD_LINT" "cppcheck" "doc_check" )
elif [ "$1" = "doc_check" ]; then
run_cmd=( "doc_check" )
else
echo ""
echo "======== $0 [Usages] ========"
echo "1) $0 format - run formating"
echo "2) $0 lint - run linting check"
echo "3) $0 all - run formating and linting"
echo "4) $0 doc_check - run documentation check"
exit 1
fi
### Formating and Linting
exitCode=0
for cmd in "${run_cmd[@]}"; do
if [ "$cmd" = "cppcheck" ]; then
cppcheck --quiet --inline-suppr --language=c++ --enable=all -I include --suppress=missingIncludeSystem --template "{file}({line}): {severity} ({id}): {message}" -iexamples/config_cli/libs ./src ./examples
result=$?
elif [ "$cmd" = "doc_check" ]; then
eval $CMD_DOC_CHECK
result=$?
else
result=$(run_cmd_on_source "$cmd")
fi
if [ $result -ne 0 ]; then
exitCode=$(($result))
fi
done
exit $exitCode