-
Notifications
You must be signed in to change notification settings - Fork 1
/
autoformat.sh
executable file
·38 lines (28 loc) · 1.01 KB
/
autoformat.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
#!/bin/bash
set -aeuo pipefail
STYLUA="stylua"
CLANG_FORMAT="clang-format"
echo "Installed formatters:"
echo
echo $(which $STYLUA)
echo $($STYLUA --version)
echo $(which $CLANG_FORMAT)
echo $($CLANG_FORMAT --version)
echo
echo "Formatting Lua sources ..."
stylua . --verbose --syntax luajit
echo "Discovering C/C++ sources ..."
RELEVANT_C_FILES_TO_FORMAT=$(find . -type f -name "*.c" -print -o -name "*.h" -print -o -path "*/deps" -prune -o -path "*/ninjabuild-*" -prune)
if [ -n "$RELEVANT_C_FILES_TO_FORMAT" ]; then
echo "Discovered C sources:"
echo $RELEVANT_C_FILES_TO_FORMAT
echo "Formatting C sources ..."
$CLANG_FORMAT -i --verbose $RELEVANT_C_FILES_TO_FORMAT
else
echo "NO relevant C sources found"
fi
RELEVANT_CPP_FILES_TO_FORMAT=$(find . -type f -name "*.cpp" -print -o -name "*.hpp" -print -o -path "*/deps" -prune -o -path "*/ninjabuild-*" -prune)
echo "Discovered C++ sources:"
echo $RELEVANT_CPP_FILES_TO_FORMAT
echo "Formatting C++ sources ..."
$CLANG_FORMAT -i --verbose $RELEVANT_CPP_FILES_TO_FORMAT