blob: 2eee61a45949de7caa733f6375ab1aa8b0347e53 (
plain)
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
73
74
75
76
77
78
|
#!/usr/bin/env bash
# Command line arguments
run_black=false
run_clang_format=false
run_fix_headers=false
usage="Invalid argument. Usage:\n$0 <option>\n\t--black|-b\n\t--clang-format|-c\n\t--headers|-h\n\t--all|-a"
if [ -z "$1" ]; then
echo -e $usage
exit 0
fi
while [ $# -gt 0 ]; do
case "$1" in
--black|-b)
run_black=true
;;
--clang-format|-c)
run_clang_format=true
;;
--headers|-h)
run_fix_headers=true
;;
--all|-a)
run_black=true
run_clang_format=true
run_fix_headers=true
;;
*)
echo -e $usage
exit 0
esac
shift
done
echo "Removing generated files, some have binary data and make clang-format freeze."
find -name "*.gen.*" -delete
# Apply black
if $run_black; then
echo -e "Formatting Python files..."
PY_FILES=$(find \( -path "./.git" \
-o -path "./thirdparty" \
\) -prune \
-o \( -name "SConstruct" \
-o -name "SCsub" \
-o -name "*.py" \
\) -print)
black -l 120 $PY_FILES
fi
# Apply clang-format
if $run_clang_format; then
# Sync list with pre-commit hook
FILE_EXTS=".c .h .cpp .hpp .cc .hh .cxx .m .mm .inc .java .glsl"
for extension in ${FILE_EXTS}; do
echo -e "Formatting ${extension} files..."
find \( -path "./.git" \
-o -path "./thirdparty" \
-o -path "./platform/android/java/lib/src/com/google" \
\) -prune \
-o -name "*${extension}" \
-exec clang-format -i {} \;
done
fi
# Add missing copyright headers
if $run_fix_headers; then
echo "Fixing copyright headers in Godot code files..."
find \( -path "./.git" -o -path "./thirdparty" \) -prune \
-o -regex '.*\.\(c\|h\|cpp\|hpp\|cc\|hh\|cxx\|m\|mm\|java\)' \
> tmp-files
cat tmp-files | grep -v ".git\|thirdparty\|theme_data.h\|platform/android/java/lib/src/com/google\|platform/android/java/lib/src/org/godotengine/godot/input/InputManager" > files
python misc/scripts/fix_headers.py
rm -f tmp-files files
fi
|