diff options
Diffstat (limited to 'misc/scripts')
-rwxr-xr-x | misc/scripts/clang_tidy.sh | 33 | ||||
-rwxr-xr-x[-rw-r--r--] | misc/scripts/dotnet_format.py | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | misc/scripts/file_format.py | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | misc/scripts/gitignore_check.sh | 0 | ||||
-rwxr-xr-x | misc/scripts/godot_gdb_pretty_print.py | 116 | ||||
-rwxr-xr-x[-rw-r--r--] | misc/scripts/header_guards.py | 0 | ||||
-rwxr-xr-x | misc/scripts/install_d3d12_sdk_windows.py | 4 |
7 files changed, 2 insertions, 151 deletions
diff --git a/misc/scripts/clang_tidy.sh b/misc/scripts/clang_tidy.sh deleted file mode 100755 index 0c6998b491..0000000000 --- a/misc/scripts/clang_tidy.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/env bash - -# This script runs clang-tidy on all relevant files in the repo. -# This is more thorough than clang-format and thus slower; it should only be run manually. - -set -uo pipefail - -# 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-tidy. - clang-tidy --quiet --fix "$f" &> /dev/null - - # Run clang-format. This also fixes the output of clang-tidy. - clang-format --Wno-error=unknown -i "$f" -done - -diff=$(git diff --color) - -# If no diff has been generated all is OK, clean up, and exit. -if [ -z "$diff" ] ; then - printf "\e[1;32m*** Files in this commit comply with the clang-tidy style rules.\e[0m\n" - exit 0 -fi - -# A diff has been created, notify the user, clean up, and exit. -printf "\n\e[1;33m*** The following changes must be made to comply with the formatting rules:\e[0m\n\n" -# Perl commands replace trailing spaces with `·` and tabs with `<TAB>`. -printf "%s\n" "$diff" | 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' - -printf "\n\e[1;91m*** Please fix your commit(s) with 'git commit --amend' or 'git rebase -i <hash>'\e[0m\n" -exit 1 diff --git a/misc/scripts/dotnet_format.py b/misc/scripts/dotnet_format.py index 51fd7a1223..51fd7a1223 100644..100755 --- a/misc/scripts/dotnet_format.py +++ b/misc/scripts/dotnet_format.py diff --git a/misc/scripts/file_format.py b/misc/scripts/file_format.py index a4ea544a45..a4ea544a45 100644..100755 --- a/misc/scripts/file_format.py +++ b/misc/scripts/file_format.py diff --git a/misc/scripts/gitignore_check.sh b/misc/scripts/gitignore_check.sh index f162e25391..f162e25391 100644..100755 --- a/misc/scripts/gitignore_check.sh +++ b/misc/scripts/gitignore_check.sh diff --git a/misc/scripts/godot_gdb_pretty_print.py b/misc/scripts/godot_gdb_pretty_print.py deleted file mode 100755 index 932831d24e..0000000000 --- a/misc/scripts/godot_gdb_pretty_print.py +++ /dev/null @@ -1,116 +0,0 @@ -#!/usr/bin/env python3 -# Load this file to your GDB session to enable pretty-printing -# of some Godot C++ types. -# GDB command: source misc/scripts/godot_gdb_pretty_print.py -# -# To load these automatically in Visual Studio Code, -# add the source command to the setupCommands of your configuration -# in launch.json. -# "setupCommands": [ -# ... -# { -# "description": "Load custom pretty-printers for Godot types.", -# "text": "source ${workspaceRoot}/misc/scripts/godot_gdb_pretty_print.py" -# } -# ] -# Other UI:s that use GDB under the hood are likely to have their own ways to achieve this. -# -# To debug this script it's easiest to use the interactive python from a command-line -# GDB session. Stop at a breakpoint, then use -# python-interactive to enter the python shell and -# acquire a Value object using gdb.selected_frame().read_var("variable name"). -# From there you can figure out how to print it nicely. -import re - -import gdb - - -# Printer for Godot StringName variables. -class GodotStringNamePrinter: - def __init__(self, value): - self.value = value - - def to_string(self): - return self.value["_data"]["name"]["_cowdata"]["_ptr"] - - # Hint that the object is string-like. - def display_hint(self): - return "string" - - -# Printer for Godot String variables. -class GodotStringPrinter: - def __init__(self, value): - self.value = value - - def to_string(self): - return self.value["_cowdata"]["_ptr"] - - # Hint that the object is string-like. - def display_hint(self): - return "string" - - -# Printer for Godot Vector variables. -class GodotVectorPrinter: - def __init__(self, value): - self.value = value - - # The COW (Copy On Write) object does a bunch of pointer arithmetic to access - # its members. - # The offsets are constants on the C++ side, optimized out, so not accessible to us. - # I'll just hard code the observed values and hope they are the same forever. - # See core/templates/cowdata.h - SIZE_OFFSET = 8 - DATA_OFFSET = 16 - - # Figures out the number of elements in the vector. - def get_size(self): - cowdata = self.value["_cowdata"] - if cowdata["_ptr"] == 0: - return 0 - else: - # The ptr member of cowdata does not point to the beginning of the - # cowdata. It points to the beginning of the data section of the cowdata. - # To get to the length section, we must back up to the beginning of the struct, - # then move back forward to the size. - # cf. CowData::_get_size - ptr = cowdata["_ptr"].cast(gdb.lookup_type("uint8_t").pointer()) - return int((ptr - self.DATA_OFFSET + self.SIZE_OFFSET).dereference()) - - # Lists children of the value, in this case the vector's items. - def children(self): - # Return nothing if ptr is null. - ptr = self.value["_cowdata"]["_ptr"] - if ptr == 0: - return - # Yield the items one by one. - for i in range(self.get_size()): - yield str(i), (ptr + i).dereference() - - def to_string(self): - return "%s [%d]" % (self.value.type.name, self.get_size()) - - # Hint that the object is array-like. - def display_hint(self): - return "array" - - -VECTOR_REGEX = re.compile("^Vector<.*$") - - -# Tries to find a pretty printer for a debugger value. -def lookup_pretty_printer(value): - if value.type.name == "StringName": - return GodotStringNamePrinter(value) - if value.type.name == "String": - return GodotStringPrinter(value) - if value.type.name and VECTOR_REGEX.match(value.type.name): - return GodotVectorPrinter(value) - return None - - -# Register our printer lookup function. -# The first parameter could be used to limit the scope of the printer -# to a specific object file, but that is unnecessary for us. -gdb.printing.register_pretty_printer(None, lookup_pretty_printer) diff --git a/misc/scripts/header_guards.py b/misc/scripts/header_guards.py index b554be5159..b554be5159 100644..100755 --- a/misc/scripts/header_guards.py +++ b/misc/scripts/header_guards.py diff --git a/misc/scripts/install_d3d12_sdk_windows.py b/misc/scripts/install_d3d12_sdk_windows.py index aed80d81a4..d7574e6222 100755 --- a/misc/scripts/install_d3d12_sdk_windows.py +++ b/misc/scripts/install_d3d12_sdk_windows.py @@ -1,15 +1,15 @@ #!/usr/bin/env python import os -import urllib.request import shutil import subprocess import sys +import urllib.request # Enable ANSI escape code support on Windows 10 and later (for colored console output). # <https://github.com/python/cpython/issues/73245> if sys.platform == "win32": - from ctypes import windll, c_int, byref + from ctypes import byref, c_int, windll stdout_handle = windll.kernel32.GetStdHandle(c_int(-11)) mode = c_int(0) |