summaryrefslogtreecommitdiff
path: root/misc
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2020-03-31 09:47:40 +0200
committerRémi Verschelde <rverschelde@gmail.com>2020-03-31 09:55:13 +0200
commit0926c192e8cca7509ace4cf015c9a1dd529393f1 (patch)
tree1b832bb21e0f74fdcdd9eae20be6cc1dd42ae6f9 /misc
parentece425ace4f5d6a684d3f04bae65f3e179393d85 (diff)
Style: Add black format to fix_style.sh
Also ignore new Android build artifact.
Diffstat (limited to 'misc')
-rwxr-xr-xmisc/scripts/fix_style.sh20
1 files changed, 19 insertions, 1 deletions
diff --git a/misc/scripts/fix_style.sh b/misc/scripts/fix_style.sh
index b33cb0a7b4..2eee61a459 100755
--- a/misc/scripts/fix_style.sh
+++ b/misc/scripts/fix_style.sh
@@ -1,9 +1,10 @@
#!/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--clang-format|-c\n\t--headers|-h\n\t--all|-a"
+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
@@ -12,6 +13,9 @@ fi
while [ $# -gt 0 ]; do
case "$1" in
+ --black|-b)
+ run_black=true
+ ;;
--clang-format|-c)
run_clang_format=true
;;
@@ -19,6 +23,7 @@ while [ $# -gt 0 ]; do
run_fix_headers=true
;;
--all|-a)
+ run_black=true
run_clang_format=true
run_fix_headers=true
;;
@@ -32,6 +37,19 @@ 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