summaryrefslogtreecommitdiffstats
path: root/misc/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'misc/scripts')
-rwxr-xr-x[-rw-r--r--]misc/scripts/fix_headers.py12
-rwxr-xr-xmisc/scripts/fix_style.sh60
-rw-r--r--misc/scripts/sort-demos.sh29
3 files changed, 66 insertions, 35 deletions
diff --git a/misc/scripts/fix_headers.py b/misc/scripts/fix_headers.py
index 48b9628b1f..d94db22b42 100644..100755
--- a/misc/scripts/fix_headers.py
+++ b/misc/scripts/fix_headers.py
@@ -9,8 +9,8 @@ header = """\
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -33,7 +33,7 @@ header = """\
/*************************************************************************/
"""
-files = open("files", "rb")
+files = open("files", "r")
fname = files.readline()
@@ -67,7 +67,7 @@ while (fname != ""):
# In a second pass, we skip all consecutive comment lines starting with "/*",
# then we can append the rest (step 2).
- fileread = open(fname.strip(), "rb")
+ fileread = open(fname.strip(), "r")
line = fileread.readline()
header_done = False
@@ -92,11 +92,11 @@ while (fname != ""):
fileread.close()
# Write
- filewrite = open(fname.strip(), "wb")
+ filewrite = open(fname.strip(), "w")
filewrite.write(text)
filewrite.close()
# Next file
fname = files.readline()
-files.close() \ No newline at end of file
+files.close()
diff --git a/misc/scripts/fix_style.sh b/misc/scripts/fix_style.sh
new file mode 100755
index 0000000000..19ca781535
--- /dev/null
+++ b/misc/scripts/fix_style.sh
@@ -0,0 +1,60 @@
+#!/bin/bash
+
+# Command line arguments
+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"
+
+if [ -z "$1" ]; then
+ echo -e $usage
+ exit 0
+fi
+
+while [ $# -gt 0 ]; do
+ case "$1" in
+ --clang-format|-c)
+ run_clang_format=true
+ ;;
+ --headers|-h)
+ run_fix_headers=true
+ ;;
+ --all|-a)
+ 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 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
diff --git a/misc/scripts/sort-demos.sh b/misc/scripts/sort-demos.sh
deleted file mode 100644
index 5e01b86b46..0000000000
--- a/misc/scripts/sort-demos.sh
+++ /dev/null
@@ -1,29 +0,0 @@
-#!/bin/bash
-# When scanning for demos, the project manager sorts them based on their
-# timestamp, i.e. last modification date. This can make for a pretty
-# messy output, so this script 'touches' each project.godot file in reverse
-# alphabetical order to ensure a nice listing.
-#
-# It's good practice to run it once before packaging demos on the build
-# server.
-
-if [ ! -d "demos" ]; then
- echo "Run this script from the root directory where 'demos/' is contained."
- exit 1
-fi
-
-if [ -e demos.list ]; then
- rm -f demos.list
-fi
-
-for dir in 2d 3d gui misc viewport; do
- find "demos/$dir" -name "project.godot" |sort >> demos.list
-done
-cat demos.list |sort -r > demos_r.list
-
-while read line; do
- touch $line
- sleep 0.2
-done < demos_r.list
-
-#rm -f demos.list demos_r.list