summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt2
-rw-r--r--misc/hooks/README.md4
-rwxr-xr-xmisc/hooks/canonicalize_filename.sh2
-rwxr-xr-xmisc/hooks/pre-commit2
-rwxr-xr-xmisc/hooks/pre-commit-black18
-rwxr-xr-xmisc/hooks/pre-commit-clang-format26
-rwxr-xr-xmisc/scripts/black_format.sh16
-rwxr-xr-xmisc/scripts/clang_format.sh55
-rw-r--r--misc/scripts/codespell.sh5
-rwxr-xr-xmisc/scripts/file_format.sh12
-rw-r--r--test/CMakeLists.txt2
11 files changed, 63 insertions, 81 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index d128e30..5cd05ff 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -79,7 +79,7 @@ if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
string(REPLACE "/RTC1" "" CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG})
endif(CMAKE_BUILD_TYPE MATCHES Debug)
- # Disable conversion warning, truncation, unreferenced var, signed missmatch, different type
+ # Disable conversion warning, truncation, unreferenced var, signed mismatch, different type
set(GODOT_COMPILE_FLAGS "${GODOT_COMPILE_FLAGS} /wd4244 /wd4305 /wd4101 /wd4018 /wd4267 /wd4099")
# Todo: Check if needed.
diff --git a/misc/hooks/README.md b/misc/hooks/README.md
index 9015910..8732237 100644
--- a/misc/hooks/README.md
+++ b/misc/hooks/README.md
@@ -12,6 +12,8 @@ contributors to make sure they comply with our requirements.
`PATH`, or if you want to enable colored output with `pygmentize`.
- Pre-commit hook for `black`: Applies `black` to the staged Python files
before accepting a commit.
+- Pre-commit hook for `make_rst`: Checks the class reference syntax using
+ `make_rst.py`.
## Installation
@@ -26,7 +28,7 @@ so they should work out of the box on Linux/macOS.
#### Windows
##### clang-format
-- Download LLVM for Windows (version 8 or later) from
+- Download LLVM for Windows (version 13 or later) from
<https://releases.llvm.org/download.html>
- Make sure LLVM is added to the `PATH` during installation
diff --git a/misc/hooks/canonicalize_filename.sh b/misc/hooks/canonicalize_filename.sh
index 5fcae6e..fe66999 100755
--- a/misc/hooks/canonicalize_filename.sh
+++ b/misc/hooks/canonicalize_filename.sh
@@ -16,7 +16,7 @@
# specified filename. This should reproduce the results of the GNU version of
# readlink with the -f option.
#
-# Reference: http://stackoverflow.com/questions/1055671/how-can-i-get-the-behavior-of-gnus-readlink-f-on-a-mac
+# Reference: https://stackoverflow.com/questions/1055671/how-can-i-get-the-behavior-of-gnus-readlink-f-on-a-mac
canonicalize_filename () {
local target_file="$1"
local physical_directory=""
diff --git a/misc/hooks/pre-commit b/misc/hooks/pre-commit
index 1d71370..ab0fc81 100755
--- a/misc/hooks/pre-commit
+++ b/misc/hooks/pre-commit
@@ -14,7 +14,7 @@
# as this script. Hooks should return 0 if successful and nonzero to cancel the
# commit. They are executed in the order in which they are listed.
#HOOKS="pre-commit-compile pre-commit-uncrustify"
-HOOKS="pre-commit-clang-format pre-commit-black"
+HOOKS="pre-commit-clang-format pre-commit-black pre-commit-make-rst"
###########################################################
# There should be no need to change anything below this line.
diff --git a/misc/hooks/pre-commit-black b/misc/hooks/pre-commit-black
index 76d9729..fd93bfe 100755
--- a/misc/hooks/pre-commit-black
+++ b/misc/hooks/pre-commit-black
@@ -14,7 +14,7 @@ DELETE_OLD_PATCHES=false
# File types to parse.
FILE_NAMES="SConstruct SCsub"
-FILE_EXTS="py"
+FILE_EXTS=".py"
# Use pygmentize instead of cat to parse diff with highlighting.
# Install it with `pip install pygments` (Linux) or `easy_install Pygments` (Mac)
@@ -139,11 +139,11 @@ fi
while true; do
if [ $terminal = "0" ] ; then
if [ -x "$ZENITY" ] ; then
- ans=$($ZENITY --text-info --filename="$patch" --width=800 --height=600 --title="Do you want to apply that patch?" --ok-label="Apply" --cancel-label="Do not apply" --extra-button="Apply and stage")
+ choice=$($ZENITY --text-info --filename="$patch" --width=800 --height=600 --title="Do you want to apply that patch?" --ok-label="Apply" --cancel-label="Do not apply" --extra-button="Apply and stage")
if [ "$?" = "0" ] ; then
yn="Y"
else
- if [ "$ans" = "Apply and stage" ] ; then
+ if [ "$choice" = "Apply and stage" ] ; then
yn="S"
else
yn="N"
@@ -151,10 +151,10 @@ while true; do
fi
elif [ -x "$XMSG" ] ; then
$XMSG -file "$patch" -buttons "Apply":100,"Apply and stage":200,"Do not apply":0 -center -default "Do not apply" -geometry 800x600 -title "Do you want to apply that patch?"
- ans=$?
- if [ "$ans" = "100" ] ; then
+ choice=$?
+ if [ "$choice" = "100" ] ; then
yn="Y"
- elif [ "$ans" = "200" ] ; then
+ elif [ "$choice" = "200" ] ; then
yn="S"
else
yn="N"
@@ -162,10 +162,10 @@ while true; do
elif [ \( \( "$OSTYPE" = "msys" \) -o \( "$OSTYPE" = "win32" \) \) -a \( -x "$PWSH" \) ]; then
winmessage="$(canonicalize_filename "./.git/hooks/winmessage.ps1")"
$PWSH -noprofile -executionpolicy bypass -file "$winmessage" -file "$patch" -buttons "Apply":100,"Apply and stage":200,"Do not apply":0 -center -default "Do not apply" -geometry 800x600 -title "Do you want to apply that patch?"
- ans=$?
- if [ "$ans" = "100" ] ; then
+ choice=$?
+ if [ "$choice" = "100" ] ; then
yn="Y"
- elif [ "$ans" = "200" ] ; then
+ elif [ "$choice" = "200" ] ; then
yn="S"
else
yn="N"
diff --git a/misc/hooks/pre-commit-clang-format b/misc/hooks/pre-commit-clang-format
index 81bc412..2ee3f56 100755
--- a/misc/hooks/pre-commit-clang-format
+++ b/misc/hooks/pre-commit-clang-format
@@ -76,11 +76,11 @@ fi
# To get consistent formatting, we recommend contributors to use the same
# clang-format version as CI.
-RECOMMENDED_CLANG_FORMAT_MAJOR_MIN="11"
-RECOMMENDED_CLANG_FORMAT_MAJOR_MAX="12"
+RECOMMENDED_CLANG_FORMAT_MAJOR_MIN="12"
+RECOMMENDED_CLANG_FORMAT_MAJOR_MAX="13"
if [ ! -x "$CLANG_FORMAT" ] ; then
- message="Error: clang-format executable not found. Please install clang-format $RECOMMENDED_CLANG_FORMAT_MAJOR.x.x."
+ message="Error: clang-format executable not found. Please install clang-format $RECOMMENDED_CLANG_FORMAT_MAJOR_MAX."
if [ ! -t 1 ] ; then
if [ -x "$ZENITY" ] ; then
@@ -108,7 +108,7 @@ CLANG_FORMAT_VERSION="$(clang-format --version | sed "s/[^0-9\.]*\([0-9\.]*\).*/
CLANG_FORMAT_MAJOR="$(echo "$CLANG_FORMAT_VERSION" | cut -d. -f1)"
if [[ "$CLANG_FORMAT_MAJOR" -lt "$RECOMMENDED_CLANG_FORMAT_MAJOR_MIN" || "$CLANG_FORMAT_MAJOR" -gt "$RECOMMENDED_CLANG_FORMAT_MAJOR_MAX" ]]; then
- echo "Warning: Your clang-format binary is the wrong version ($CLANG_FORMAT_VERSION, expected between $RECOMMENDED_CLANG_FORMAT_MAJOR_MIN.x.x and $RECOMMENDED_CLANG_FORMAT_MAJOR_MAX.x.x)."
+ echo "Warning: Your clang-format binary is the wrong version ($CLANG_FORMAT_VERSION, expected between $RECOMMENDED_CLANG_FORMAT_MAJOR_MIN and $RECOMMENDED_CLANG_FORMAT_MAJOR_MAX)."
echo " Consider upgrading or downgrading clang-format as formatting may not be applied correctly."
fi
@@ -146,7 +146,7 @@ do
# +++ - timestamp
# to both lines working on the same file and having a/ and b/ prefix.
# Else it can not be applied with 'git apply'.
- "$CLANG_FORMAT" -style=file "$file" | \
+ "$CLANG_FORMAT" -style=file "$file" --Wno-error=unknown | \
diff -u "$file" - | \
sed -e "1s|--- |--- a/|" -e "2s|+++ -|+++ b/$file|" >> "$patch"
done
@@ -179,11 +179,11 @@ fi
while true; do
if [ $terminal = "0" ] ; then
if [ -x "$ZENITY" ] ; then
- ans=$($ZENITY --text-info --filename="$patch" --width=800 --height=600 --title="Do you want to apply that patch?" --ok-label="Apply" --cancel-label="Do not apply" --extra-button="Apply and stage")
+ choice=$($ZENITY --text-info --filename="$patch" --width=800 --height=600 --title="Do you want to apply that patch?" --ok-label="Apply" --cancel-label="Do not apply" --extra-button="Apply and stage")
if [ "$?" = "0" ] ; then
yn="Y"
else
- if [ "$ans" = "Apply and stage" ] ; then
+ if [ "$choice" = "Apply and stage" ] ; then
yn="S"
else
yn="N"
@@ -191,10 +191,10 @@ while true; do
fi
elif [ -x "$XMSG" ] ; then
$XMSG -file "$patch" -buttons "Apply":100,"Apply and stage":200,"Do not apply":0 -center -default "Do not apply" -geometry 800x600 -title "Do you want to apply that patch?"
- ans=$?
- if [ "$ans" = "100" ] ; then
+ choice=$?
+ if [ "$choice" = "100" ] ; then
yn="Y"
- elif [ "$ans" = "200" ] ; then
+ elif [ "$choice" = "200" ] ; then
yn="S"
else
yn="N"
@@ -202,10 +202,10 @@ while true; do
elif [ \( \( "$OSTYPE" = "msys" \) -o \( "$OSTYPE" = "win32" \) \) -a \( -x "$PWSH" \) ]; then
winmessage="$(canonicalize_filename "./.git/hooks/winmessage.ps1")"
$PWSH -noprofile -executionpolicy bypass -file "$winmessage" -file "$patch" -buttons "Apply":100,"Apply and stage":200,"Do not apply":0 -center -default "Do not apply" -geometry 800x600 -title "Do you want to apply that patch?"
- ans=$?
- if [ "$ans" = "100" ] ; then
+ choice=$?
+ if [ "$choice" = "100" ] ; then
yn="Y"
- elif [ "$ans" = "200" ] ; then
+ elif [ "$choice" = "200" ] ; then
yn="S"
else
yn="N"
diff --git a/misc/scripts/black_format.sh b/misc/scripts/black_format.sh
index f93e8cb..99343f1 100755
--- a/misc/scripts/black_format.sh
+++ b/misc/scripts/black_format.sh
@@ -6,28 +6,20 @@ set -uo pipefail
# Apply black.
echo -e "Formatting Python files..."
-PY_FILES=$(find \( -path "./.git" \
- -o -path "./thirdparty" \
- \) -prune \
- -o \( -name "SConstruct" \
- -o -name "SCsub" \
- -o -name "*.py" \
- \) -print)
+PY_FILES=$(git ls-files -- '*SConstruct' '*SCsub' '*.py' ':!:.git/*' ':!:thirdparty/*')
black -l 120 $PY_FILES
-git diff > patch.patch
+diff=$(git diff --color)
# If no patch has been generated all is OK, clean up, and exit.
-if [ ! -s patch.patch ] ; then
+if [ -z "$diff" ] ; then
printf "Files in this commit comply with the black style rules.\n"
- rm -f patch.patch
exit 0
fi
# A patch has been created, notify the user, clean up, and exit.
printf "\n*** The following differences were found between the code "
printf "and the formatting rules:\n\n"
-cat patch.patch
+echo "$diff"
printf "\n*** Aborting, please fix your commit(s) with 'git commit --amend' or 'git rebase -i <hash>'\n"
-rm -f patch.patch
exit 1
diff --git a/misc/scripts/clang_format.sh b/misc/scripts/clang_format.sh
index 955ff68..13b5ab7 100755
--- a/misc/scripts/clang_format.sh
+++ b/misc/scripts/clang_format.sh
@@ -4,57 +4,36 @@
# This is the primary script responsible for fixing style violations.
set -uo pipefail
-IFS=$'\n\t'
-CLANG_FORMAT_FILE_EXTS=(".c" ".h" ".cpp" ".hpp" ".cc" ".hh" ".cxx" ".m" ".mm" ".inc" ".java" ".glsl")
+# Loops through all code files tracked by Git.
+git ls-files -- '*.c' '*.h' '*.cpp' '*.hpp' '*.cc' '*.hh' '*.cxx' '*.m' '*.mm' '*.inc' '*.java' '*.glsl' \
+ ':!:.git/*' ':!:thirdparty/*' ':!:platform/android/java/lib/src/com/google/*' ':!:*-so_wrap.*' |
+while read -r f; do
+ # Run clang-format.
+ clang-format --Wno-error=unknown -i "$f"
-# Loops through all text files tracked by Git.
-git grep -zIl '' |
-while IFS= read -rd '' f; do
- # Exclude some files.
- if [[ "$f" == "thirdparty"* ]]; then
+ # Fix copyright headers, but not all files get them.
+ if [[ "$f" == *"inc" ]]; then
continue
- # elif [[ "$f" == "gen"* ]]; then
- # continue
- elif [[ "$f" == "platform/android/java/lib/src/com/google"* ]]; then
+ elif [[ "$f" == *"glsl" ]]; then
continue
- elif [[ "$f" == *"-so_wrap."* ]]; then
+ elif [[ "$f" == "platform/android/java/lib/src/org/godotengine/godot/input/InputManager"* ]]; then
continue
fi
- for extension in ${CLANG_FORMAT_FILE_EXTS[@]}; do
- if [[ "$f" == *"$extension" ]]; then
- # Run clang-format.
- clang-format -i "$f"
- # Fix copyright headers, but not all files get them.
- if [[ "$f" == *"inc" ]]; then
- continue 2
- elif [[ "$f" == *"glsl" ]]; then
- continue 2
- elif [[ "$f" == *"theme_data.h" ]]; then
- continue 2
- elif [[ "$f" == "platform/android/java/lib/src/org/godotengine/godot/input/InputManager"* ]]; then
- continue 2
- fi
- python misc/scripts/copyright_headers.py "$f"
- continue 2
- fi
- done
+ python misc/scripts/copyright_headers.py "$f"
done
-git diff > patch.patch
+diff=$(git diff --color)
# If no patch has been generated all is OK, clean up, and exit.
-if [ ! -s patch.patch ] ; then
- printf "Files in this commit comply with the clang-format style rules.\n"
- rm -f patch.patch
+if [ -z "$diff" ] ; then
+ printf "Files in this commit comply with the clang-tidy style rules.\n"
exit 0
fi
# A patch has been created, notify the user, clean up, and exit.
-printf "\n*** The following differences were found between the code "
-printf "and the formatting rules:\n\n"
-cat patch.patch
-printf "\n*** Aborting, please fix your commit(s) with 'git commit --amend' or 'git rebase -i <hash>'\n"
-rm -f patch.patch
+printf "\n*** The following changes have been made to comply with the formatting rules:\n\n"
+echo "$diff"
+printf "\n*** Please fix your commit(s) with 'git commit --amend' or 'git rebase -i <hash>'\n"
exit 1
diff --git a/misc/scripts/codespell.sh b/misc/scripts/codespell.sh
new file mode 100644
index 0000000..2822c64
--- /dev/null
+++ b/misc/scripts/codespell.sh
@@ -0,0 +1,5 @@
+#!/bin/sh
+SKIP_LIST="./thirdparty,*.gen.*,*.po,*.pot,package-lock.json,./core/string/locales.h,./DONORS.md,./misc/scripts/codespell.sh"
+IGNORE_LIST="ba,childs,curvelinear,expct,fave,findn,gird,inout,lod,nd,numer,ois,ro,statics,te,varn"
+
+codespell -w -q 3 -S "${SKIP_LIST}" -L "${IGNORE_LIST}"
diff --git a/misc/scripts/file_format.sh b/misc/scripts/file_format.sh
index 795431c..0c72358 100755
--- a/misc/scripts/file_format.sh
+++ b/misc/scripts/file_format.sh
@@ -20,6 +20,11 @@ while IFS= read -rd '' f; do
continue
elif [[ "$f" == *"sln" ]]; then
continue
+ elif [[ "$f" == *".bat" ]]; then
+ continue
+ elif [[ "$f" == *".out" ]]; then
+ # GDScript integration testing files.
+ continue
elif [[ "$f" == *"patch" ]]; then
continue
elif [[ "$f" == *"pot" ]]; then
@@ -42,10 +47,10 @@ while IFS= read -rd '' f; do
perl -i -ple 's/\s*$//g' "$f"
done
-git diff > patch.patch
+diff=$(git diff --color)
# If no patch has been generated all is OK, clean up, and exit.
-if [ ! -s patch.patch ] ; then
+if [ -z "$diff" ] ; then
printf "Files in this commit comply with the formatting rules.\n"
rm -f patch.patch
exit 0
@@ -54,7 +59,6 @@ fi
# A patch has been created, notify the user, clean up, and exit.
printf "\n*** The following differences were found between the code "
printf "and the formatting rules:\n\n"
-cat patch.patch
+echo "$diff"
printf "\n*** Aborting, please fix your commit(s) with 'git commit --amend' or 'git rebase -i <hash>'\n"
-rm -f patch.patch
exit 1
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 05422bd..b556304 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -47,7 +47,7 @@ if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
string(REPLACE "/RTC1" "" CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG})
endif(CMAKE_BUILD_TYPE MATCHES Debug)
- # Disable conversion warning, trunkation, unreferenced var, signed missmatch
+ # Disable conversion warning, truncation, unreferenced var, signed mismatch
set(GODOT_COMPILE_FLAGS "${GODOT_COMPILE_FLAGS} /wd4244 /wd4305 /wd4101 /wd4018 /wd4267")
# Todo: Check if needed.