summaryrefslogtreecommitdiffstats
path: root/misc/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'misc/scripts')
-rwxr-xr-xmisc/scripts/clang_tidy.sh33
-rwxr-xr-xmisc/scripts/godot_gdb_pretty_print.py116
-rwxr-xr-xmisc/scripts/header_guards.py37
-rwxr-xr-xmisc/scripts/install_d3d12_sdk_windows.py29
4 files changed, 31 insertions, 184 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/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..fed418db1e 100755
--- a/misc/scripts/header_guards.py
+++ b/misc/scripts/header_guards.py
@@ -8,22 +8,38 @@ if len(sys.argv) < 2:
print("Invalid usage of header_guards.py, it should be called with a path to one or multiple files.")
sys.exit(1)
-HEADER_CHECK_OFFSET = 30
-HEADER_BEGIN_OFFSET = 31
-HEADER_END_OFFSET = -1
-
changed = []
invalid = []
for file in sys.argv[1:]:
- with open(file, "rt", encoding="utf-8", newline="\n") as f:
+ header_start = -1
+ HEADER_CHECK_OFFSET = -1
+
+ with open(file.strip(), "rt", encoding="utf-8", newline="\n") as f:
lines = f.readlines()
- if len(lines) <= HEADER_BEGIN_OFFSET:
- continue # Most likely a dummy file.
+ for idx, line in enumerate(lines):
+ sline = line.strip()
+
+ if header_start < 0:
+ if sline == "": # Skip empty lines at the top.
+ continue
+
+ if sline.startswith("/**********"): # Godot header starts this way.
+ header_start = idx
+ else:
+ HEADER_CHECK_OFFSET = 0 # There is no Godot header.
+ break
+ else:
+ if not sline.startswith("*") and not sline.startswith("/*"): # Not in the Godot header anymore.
+ HEADER_CHECK_OFFSET = idx + 1 # The include should be two lines below the Godot header.
+ break
+
+ if HEADER_CHECK_OFFSET < 0:
+ continue
- if lines[HEADER_CHECK_OFFSET].startswith("#import"):
- continue # Early catch obj-c file.
+ HEADER_BEGIN_OFFSET = HEADER_CHECK_OFFSET + 1
+ HEADER_END_OFFSET = len(lines) - 1
split = file.split("/") # Already in posix-format.
@@ -82,6 +98,9 @@ for file in sys.argv[1:]:
objc = False
for idx, line in enumerate(lines):
+ if line.startswith("// #import"): # Some dummy obj-c files only have commented out import lines.
+ objc = True
+ break
if not line.startswith("#"):
continue
elif line.startswith("#ifndef") and header_check == -1:
diff --git a/misc/scripts/install_d3d12_sdk_windows.py b/misc/scripts/install_d3d12_sdk_windows.py
index d7574e6222..2e5e4fce18 100755
--- a/misc/scripts/install_d3d12_sdk_windows.py
+++ b/misc/scripts/install_d3d12_sdk_windows.py
@@ -25,12 +25,6 @@ if deps_folder:
else:
deps_folder = os.path.join("bin", "build_deps")
-# DirectX Shader Compiler
-# Check for latest version: https://github.com/microsoft/DirectXShaderCompiler/releases/latest
-dxc_version = "v1.8.2403.2"
-dxc_filename = "dxc_2024_03_29.zip"
-dxc_archive = os.path.join(deps_folder, dxc_filename)
-dxc_folder = os.path.join(deps_folder, "dxc")
# Mesa NIR
# Check for latest version: https://github.com/godotengine/godot-nir-static/releases/latest
mesa_version = "23.1.9"
@@ -54,25 +48,8 @@ agility_sdk_folder = os.path.join(deps_folder, "agility_sdk")
if not os.path.exists(deps_folder):
os.makedirs(deps_folder)
-# DirectX Shader Compiler
-print("\x1b[1m[1/4] DirectX Shader Compiler\x1b[0m")
-if os.path.isfile(dxc_archive):
- os.remove(dxc_archive)
-print(f"Downloading DirectX Shader Compiler {dxc_filename} ...")
-urllib.request.urlretrieve(
- f"https://github.com/microsoft/DirectXShaderCompiler/releases/download/{dxc_version}/{dxc_filename}",
- dxc_archive,
-)
-if os.path.exists(dxc_folder):
- print(f"Removing existing local DirectX Shader Compiler installation in {dxc_folder} ...")
- shutil.rmtree(dxc_folder)
-print(f"Extracting DirectX Shader Compiler {dxc_filename} to {dxc_folder} ...")
-shutil.unpack_archive(dxc_archive, dxc_folder)
-os.remove(dxc_archive)
-print(f"DirectX Shader Compiler {dxc_filename} installed successfully.\n")
-
# Mesa NIR
-print("\x1b[1m[2/4] Mesa NIR\x1b[0m")
+print("\x1b[1m[1/3] Mesa NIR\x1b[0m")
if os.path.isfile(mesa_archive):
os.remove(mesa_archive)
print(f"Downloading Mesa NIR {mesa_filename} ...")
@@ -99,7 +76,7 @@ if dlltool == "":
dlltool = shutil.which("x86_64-w64-mingw32-dlltool") or ""
has_mingw = gendef != "" and dlltool != ""
-print("\x1b[1m[3/4] WinPixEventRuntime\x1b[0m")
+print("\x1b[1m[2/3] WinPixEventRuntime\x1b[0m")
if os.path.isfile(pix_archive):
os.remove(pix_archive)
print(f"Downloading WinPixEventRuntime {pix_version} ...")
@@ -130,7 +107,7 @@ else:
print(f"WinPixEventRuntime {pix_version} installed successfully.\n")
# DirectX 12 Agility SDK
-print("\x1b[1m[4/4] DirectX 12 Agility SDK\x1b[0m")
+print("\x1b[1m[3/3] DirectX 12 Agility SDK\x1b[0m")
if os.path.isfile(agility_sdk_archive):
os.remove(agility_sdk_archive)
print(f"Downloading DirectX 12 Agility SDK {agility_sdk_version} ...")