forked from ouster-lidar/ouster-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
clang-linting.sh
executable file
·42 lines (37 loc) · 961 Bytes
/
clang-linting.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
#!/bin/bash
help='false'
apply='false'
check='true'
SUBCOMMAND='--Werror --dry-run'
#Input arguments
while getopts 'ha' flag
do
case "${flag}" in
h) help='true';;
a) apply='true';;
esac
done
if [[ $help == 'true' ]]; then
echo """
How to run:
cd ouster-sdk; then run ./clang-linting.sh
Default: performs a clang format check and prints errors if they exist
./clang-linting.sh -a
applies the clang format to the files
"""
fi
if [[ $apply == 'true' ]]; then
check='false'
SUBCOMMAND=''
fi
# Ignore the ./ouster_client/include/optional-lite/nonstd/optional.hpp file while formatting files
CMD="find . -regex '.*\.\(cpp\|hpp\|cu\|c\|h\)' -not -path ./ouster_client/include/optional-lite/nonstd/optional.hpp \
-exec clang-format ${SUBCOMMAND} -style=file -i {} \;"
OUTPUT=$(eval "$CMD" 2>&1 | grep error)
if [ -z "$OUTPUT" ]; then
echo "clang-format check passed! No errors"
exit 0;
else
eval "$CMD"
exit 1;
fi