-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclang-format.sh
More file actions
executable file
·31 lines (24 loc) · 870 Bytes
/
Copy pathclang-format.sh
File metadata and controls
executable file
·31 lines (24 loc) · 870 Bytes
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
#!/usr/bin/sh
# Format sources with Clang-Format using .clang-format configuration
function check_util() {
if [ ! -f "$(command -v "$1")" ]; then
echo "Utility \"$1\" is no install"
exit 1
fi
}
function format_file() {
find "$1" -type f \( -name "*.cpp" -o -name "*.hpp" -o -name "*.h" -o -name "*.c" \) -exec sh -c 'truncate -s 0 /tmp/_______format && clang-format --assume-filename=.clang-format {} | tee /tmp/_______format > /dev/null && mv /tmp/_______format {}' \;
}
check_util dirname
check_util readlink
check_util clang-format
check_util find
check_util tee
check_util truncate
_script_path=$(dirname "$(readlink -f "$0")")
format_file "${_script_path}/include"
format_file "${_script_path}/src"
format_file "${_script_path}/ui"
format_file "${_script_path}/update"
format_file "${_script_path}/3rdParty"
echo "format success"