Skip to content

Commit f4bc581

Browse files
committed
Restore all the scripts.
1 parent 8d976e4 commit f4bc581

12 files changed

+429
-0
lines changed

misc/scripts/check_ci_log.py

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
4+
import sys
5+
6+
if len(sys.argv) < 2:
7+
print("ERROR: You must run program with file name as argument.")
8+
sys.exit(50)
9+
10+
fname = sys.argv[1]
11+
12+
fileread = open(fname.strip(), "r")
13+
file_contents = fileread.read()
14+
15+
# If find "ERROR: AddressSanitizer:", then happens invalid read or write
16+
# This is critical bug, so we need to fix this as fast as possible
17+
18+
if file_contents.find("ERROR: AddressSanitizer:") != -1:
19+
print("FATAL ERROR: An incorrectly used memory was found.")
20+
sys.exit(51)
21+
22+
# There is also possible, that program crashed with or without backtrace.
23+
24+
if (
25+
file_contents.find("Program crashed with signal") != -1
26+
or file_contents.find("Dumping the backtrace") != -1
27+
or file_contents.find("Segmentation fault (core dumped)") != -1
28+
or file_contents.find("Aborted (core dumped)") != -1
29+
or file_contents.find("terminate called without an active exception") != -1
30+
):
31+
print("FATAL ERROR: Godot has been crashed.")
32+
sys.exit(52)
33+
34+
# Finding memory leaks in Godot is quite difficult, because we need to take into
35+
# account leaks also in external libraries. They are usually provided without
36+
# debugging symbols, so the leak report from it usually has only 2/3 lines,
37+
# so searching for 5 element - "#4 0x" - should correctly detect the vast
38+
# majority of memory leaks
39+
40+
if file_contents.find("ERROR: LeakSanitizer:") != -1:
41+
if file_contents.find("#4 0x") != -1:
42+
print("ERROR: Memory leak was found")
43+
sys.exit(53)
44+
45+
# It may happen that Godot detects leaking nodes/resources and removes them, so
46+
# this possibility should also be handled as a potential error, even if
47+
# LeakSanitizer doesn't report anything
48+
49+
if file_contents.find("ObjectDB instances leaked at exit") != -1:
50+
print("ERROR: Memory leak was found")
51+
sys.exit(54)
52+
53+
# In test project may be put several assert functions which will control if
54+
# project is executed with right parameters etc. which normally will not stop
55+
# execution of project
56+
57+
if file_contents.find("Assertion failed") != -1:
58+
print("ERROR: Assertion failed in project, check execution log for more info")
59+
sys.exit(55)
60+
61+
# For now Godot leaks a lot of rendering stuff so for now we just show info
62+
# about it and this needs to be re-enabled after fixing this memory leaks.
63+
64+
if file_contents.find("were leaked") != -1 or file_contents.find("were never freed") != -1:
65+
print("WARNING: Memory leak was found")
66+
67+
sys.exit(0)

misc/scripts/clang_format.sh

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#!/usr/bin/env bash
2+
3+
# This script runs clang-format and fixes copyright headers on all relevant files in the repo.
4+
# This is the primary script responsible for fixing style violations.
5+
6+
set -uo pipefail
7+
8+
if [ $# -eq 0 ]; then
9+
# Loop through all code files tracked by Git.
10+
files=$(git ls-files -- '*.c' '*.h' '*.cpp' '*.hpp' '*.cc' '*.hh' '*.cxx' '*.m' '*.mm' '*.inc' '*.java' '*.glsl' \
11+
':!:.git/*' ':!:thirdparty/*' ':!:*/thirdparty/*' ':!:platform/android/java/lib/src/com/google/*' \
12+
':!:*-so_wrap.*' ':!:tests/python_build/*')
13+
else
14+
# $1 should be a file listing file paths to process. Used in CI.
15+
files=$(cat "$1" | grep -v "thirdparty/" | grep -E "\.(c|h|cpp|hpp|cc|hh|cxx|m|mm|inc|java|glsl)$" | grep -v "platform/android/java/lib/src/com/google/" | grep -v "\-so_wrap\." | grep -v "tests/python_build/")
16+
fi
17+
18+
if [ ! -z "$files" ]; then
19+
clang-format --Wno-error=unknown -i $files
20+
fi
21+
22+
# Fix copyright headers, but not all files get them.
23+
for f in $files; do
24+
if [[ "$f" == *"inc" ]]; then
25+
continue
26+
elif [[ "$f" == *"glsl" ]]; then
27+
continue
28+
elif [[ "$f" == "platform/android/java/lib/src/org/godotengine/godot/gl/GLSurfaceView"* ]]; then
29+
continue
30+
elif [[ "$f" == "platform/android/java/lib/src/org/godotengine/godot/gl/EGLLogWrapper"* ]]; then
31+
continue
32+
elif [[ "$f" == "platform/android/java/lib/src/org/godotengine/godot/utils/ProcessPhoenix"* ]]; then
33+
continue
34+
fi
35+
36+
python misc/scripts/copyright_headers.py "$f"
37+
done
38+
39+
diff=$(git diff --color)
40+
41+
# If no diff has been generated all is OK, clean up, and exit.
42+
if [ -z "$diff" ] ; then
43+
printf "\e[1;32m*** Files in this commit comply with the clang-format style rules.\e[0m\n"
44+
exit 0
45+
fi
46+
47+
# A diff has been created, notify the user, clean up, and exit.
48+
printf "\n\e[1;33m*** The following changes must be made to comply with the formatting rules:\e[0m\n\n"
49+
# Perl commands replace trailing spaces with `·` and tabs with `<TAB>`.
50+
printf "$diff\n" | perl -pe 's/(.*[^ ])( +)(\e\[m)$/my $spaces="·" x length($2); sprintf("$1$spaces$3")/ge' | perl -pe 's/(.*[^\t])(\t+)(\e\[m)$/my $tabs="<TAB>" x length($2); sprintf("$1$tabs$3")/ge'
51+
52+
printf "\n\e[1;91m*** Please fix your commit(s) with 'git commit --amend' or 'git rebase -i <hash>'\e[0m\n"
53+
exit 1

misc/scripts/clang_tidy.sh

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/usr/bin/env bash
2+
3+
# This script runs clang-tidy on all relevant files in the repo.
4+
# This is more thorough than clang-format and thus slower; it should only be run manually.
5+
6+
set -uo pipefail
7+
8+
# Loops through all code files tracked by Git.
9+
git ls-files -- '*.c' '*.h' '*.cpp' '*.hpp' '*.cc' '*.hh' '*.cxx' '*.m' '*.mm' '*.inc' '*.java' '*.glsl' \
10+
':!:.git/*' ':!:thirdparty/*' ':!:platform/android/java/lib/src/com/google/*' ':!:*-so_wrap.*' |
11+
while read -r f; do
12+
# Run clang-tidy.
13+
clang-tidy --quiet --fix "$f" &> /dev/null
14+
15+
# Run clang-format. This also fixes the output of clang-tidy.
16+
clang-format --Wno-error=unknown -i "$f"
17+
done
18+
19+
diff=$(git diff --color)
20+
21+
# If no diff has been generated all is OK, clean up, and exit.
22+
if [ -z "$diff" ] ; then
23+
printf "\e[1;32m*** Files in this commit comply with the clang-tidy style rules.\e[0m\n"
24+
exit 0
25+
fi
26+
27+
# A diff has been created, notify the user, clean up, and exit.
28+
printf "\n\e[1;33m*** The following changes must be made to comply with the formatting rules:\e[0m\n\n"
29+
# Perl commands replace trailing spaces with `·` and tabs with `<TAB>`.
30+
printf "$diff\n" | perl -pe 's/(.*[^ ])( +)(\e\[m)$/my $spaces="·" x length($2); sprintf("$1$spaces$3")/ge' | perl -pe 's/(.*[^\t])(\t+)(\e\[m)$/my $tabs="<TAB>" x length($2); sprintf("$1$tabs$3")/ge'
31+
32+
printf "\n\e[1;91m*** Please fix your commit(s) with 'git commit --amend' or 'git rebase -i <hash>'\e[0m\n"
33+
exit 1

misc/scripts/codespell.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/sh
2+
SKIP_LIST="./.*,./**/.*,./bin,./thirdparty,*.desktop,*.gen.*,*.po,*.pot,*.rc,./AUTHORS.md,./COPYRIGHT.txt,./DONORS.md,"
3+
SKIP_LIST+="./core/input/gamecontrollerdb.txt,./core/string/locales.h,./editor/renames_map_3_to_4.cpp,./misc/scripts/codespell.sh,"
4+
SKIP_LIST+="./platform/android/java/lib/src/com,./platform/web/node_modules,./platform/web/package-lock.json,"
5+
6+
IGNORE_LIST="curvelinear,doubleclick,expct,findn,gird,hel,inout,lod,nd,numer,ot,te,vai"
7+
8+
codespell -w -q 3 -S "${SKIP_LIST}" -L "${IGNORE_LIST}" --builtin "clear,rare,en-GB_to_en-US"

misc/scripts/copyright_headers.py

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
4+
import sys
5+
6+
header = """\
7+
/**************************************************************************/
8+
/* $filename */
9+
/**************************************************************************/
10+
/* This file is part of: */
11+
/* GODOT ENGINE */
12+
/* https://godotengine.org */
13+
/**************************************************************************/
14+
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
15+
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
16+
/* */
17+
/* Permission is hereby granted, free of charge, to any person obtaining */
18+
/* a copy of this software and associated documentation files (the */
19+
/* "Software"), to deal in the Software without restriction, including */
20+
/* without limitation the rights to use, copy, modify, merge, publish, */
21+
/* distribute, sublicense, and/or sell copies of the Software, and to */
22+
/* permit persons to whom the Software is furnished to do so, subject to */
23+
/* the following conditions: */
24+
/* */
25+
/* The above copyright notice and this permission notice shall be */
26+
/* included in all copies or substantial portions of the Software. */
27+
/* */
28+
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
29+
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
30+
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
31+
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
32+
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
33+
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
34+
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
35+
/**************************************************************************/
36+
"""
37+
38+
fname = sys.argv[1]
39+
40+
# Handle replacing $filename with actual filename and keep alignment
41+
fsingle = fname.strip()
42+
if fsingle.find("/") != -1:
43+
fsingle = fsingle[fsingle.rfind("/") + 1 :]
44+
rep_fl = "$filename"
45+
rep_fi = fsingle
46+
len_fl = len(rep_fl)
47+
len_fi = len(rep_fi)
48+
# Pad with spaces to keep alignment
49+
if len_fi < len_fl:
50+
for x in range(len_fl - len_fi):
51+
rep_fi += " "
52+
elif len_fl < len_fi:
53+
for x in range(len_fi - len_fl):
54+
rep_fl += " "
55+
if header.find(rep_fl) != -1:
56+
text = header.replace(rep_fl, rep_fi)
57+
else:
58+
text = header.replace("$filename", fsingle)
59+
text += "\n"
60+
61+
# We now have the proper header, so we want to ignore the one in the original file
62+
# and potentially empty lines and badly formatted lines, while keeping comments that
63+
# come after the header, and then keep everything non-header unchanged.
64+
# To do so, we skip empty lines that may be at the top in a first pass.
65+
# In a second pass, we skip all consecutive comment lines starting with "/*",
66+
# then we can append the rest (step 2).
67+
68+
fileread = open(fname.strip(), "r")
69+
line = fileread.readline()
70+
header_done = False
71+
72+
while line.strip() == "": # Skip empty lines at the top
73+
line = fileread.readline()
74+
75+
if line.find("/**********") == -1: # Godot header starts this way
76+
# Maybe starting with a non-Godot comment, abort header magic
77+
header_done = True
78+
79+
while not header_done: # Handle header now
80+
if line.find("/*") != 0: # No more starting with a comment
81+
header_done = True
82+
if line.strip() != "":
83+
text += line
84+
line = fileread.readline()
85+
86+
while line != "": # Dump everything until EOF
87+
text += line
88+
line = fileread.readline()
89+
90+
fileread.close()
91+
92+
# Write
93+
filewrite = open(fname.strip(), "w")
94+
filewrite.write(text)
95+
filewrite.close()

misc/scripts/dotnet_format.sh

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/usr/bin/env bash
2+
3+
# This script runs dotnet format on all relevant files in the repo.
4+
# This is the primary script responsible for fixing style violations in C# files.
5+
6+
set -uo pipefail
7+
8+
# Create dummy generated files.
9+
echo "<Project />" > modules/mono/SdkPackageVersions.props
10+
mkdir -p modules/mono/glue/GodotSharp/GodotSharp/Generated
11+
echo "<Project />" > modules/mono/glue/GodotSharp/GodotSharp/Generated/GeneratedIncludes.props
12+
mkdir -p modules/mono/glue/GodotSharp/GodotSharpEditor/Generated
13+
echo "<Project />" > modules/mono/glue/GodotSharp/GodotSharpEditor/Generated/GeneratedIncludes.props
14+
15+
# Loops through all C# projects tracked by Git.
16+
git ls-files -- '*.csproj' \
17+
':!:.git/*' ':!:thirdparty/*' ':!:platform/android/java/lib/src/com/google/*' ':!:*-so_wrap.*' |
18+
while read -r f; do
19+
# Run dotnet format.
20+
dotnet format "$f"
21+
done
22+
23+
diff=$(git diff --color)
24+
25+
# If no diff has been generated all is OK, clean up, and exit.
26+
if [ -z "$diff" ] ; then
27+
printf "\e[1;32m*** Files in this commit comply with the dotnet format style rules.\e[0m\n"
28+
exit 0
29+
fi
30+
31+
# A diff has been created, notify the user, clean up, and exit.
32+
printf "\n\e[1;33m*** The following changes must be made to comply with the formatting rules:\e[0m\n\n"
33+
# Perl commands replace trailing spaces with `·` and tabs with `<TAB>`.
34+
printf "$diff\n" | perl -pe 's/(.*[^ ])( +)(\e\[m)$/my $spaces="·" x length($2); sprintf("$1$spaces$3")/ge' | perl -pe 's/(.*[^\t])(\t+)(\e\[m)$/my $tabs="<TAB>" x length($2); sprintf("$1$tabs$3")/ge'
35+
36+
printf "\n\e[1;91m*** Please fix your commit(s) with 'git commit --amend' or 'git rebase -i <hash>'\e[0m\n"
37+
exit 1
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env sh
2+
3+
set -euo pipefail
4+
IFS=$'\n\t'
5+
6+
# Download and install the Vulkan SDK.
7+
curl -L "https://sdk.lunarg.com/sdk/download/latest/mac/vulkan-sdk.dmg" -o /tmp/vulkan-sdk.dmg
8+
hdiutil attach /tmp/vulkan-sdk.dmg -mountpoint /Volumes/vulkan-sdk
9+
/Volumes/vulkan-sdk/InstallVulkan.app/Contents/MacOS/InstallVulkan \
10+
--accept-licenses --default-answer --confirm-command install
11+
12+
cnt=5
13+
until hdiutil detach -force /Volumes/vulkan-sdk
14+
do
15+
[[ cnt -eq "0" ]] && break
16+
sleep 1
17+
((cnt--))
18+
done
19+
20+
rm -f /tmp/vulkan-sdk.dmg
21+
22+
echo 'Vulkan SDK installed successfully! You can now build Godot by running "scons".'

misc/scripts/make_icons.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/usr/bin/env bash
2+
3+
# Generate .ico, .icns and .zip set of icons for Steam
4+
5+
# Make icons with transparent backgrounds and all sizes
6+
for s in 16 24 32 48 64 128 256 512 1024; do
7+
convert -resize ${s}x$s -antialias \
8+
-background transparent \
9+
../../icon.svg icon$s.png
10+
done
11+
12+
# 16px tga file for library
13+
convert icon16.png icon16.tga
14+
15+
# zip for Linux
16+
zip godot-icons.zip icon*.png
17+
18+
# ico for Windows
19+
# Not including biggest ones or it blows up in size
20+
icotool -c -o godot-icon.ico icon{16,24,32,48,64,128,256}.png
21+
22+
# icns for macOS
23+
# Only some sizes: https://iconhandbook.co.uk/reference/chart/osx/
24+
png2icns godot-icon.icns icon{16,32,128,256,512,1024}.png
25+
26+
rm -f icon*.png

0 commit comments

Comments
 (0)