diff options
Diffstat (limited to 'misc/scripts')
-rwxr-xr-x | misc/scripts/black_format.sh | 26 | ||||
-rwxr-xr-x | misc/scripts/clang_format.sh | 53 | ||||
-rw-r--r-- | misc/scripts/dotnet_format.py | 30 | ||||
-rwxr-xr-x | misc/scripts/dotnet_format.sh | 37 | ||||
-rw-r--r-- | misc/scripts/install_d3d12_sdk_windows.py | 34 |
5 files changed, 61 insertions, 119 deletions
diff --git a/misc/scripts/black_format.sh b/misc/scripts/black_format.sh deleted file mode 100755 index 48dc14c734..0000000000 --- a/misc/scripts/black_format.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/env bash - -# This script runs black on all Python files in the repo. - -set -uo pipefail - -# Apply black. -echo -e "Formatting Python files..." -PY_FILES=$(git ls-files -- '*SConstruct' '*SCsub' '*.py' ':!:.git/*' ':!:thirdparty/*') -black -l 120 $PY_FILES - -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 black 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/clang_format.sh b/misc/scripts/clang_format.sh deleted file mode 100755 index 8b59519606..0000000000 --- a/misc/scripts/clang_format.sh +++ /dev/null @@ -1,53 +0,0 @@ -#!/usr/bin/env bash - -# This script runs clang-format and fixes copyright headers on all relevant files in the repo. -# This is the primary script responsible for fixing style violations. - -set -uo pipefail - -if [ $# -eq 0 ]; then - # Loop through all code files tracked by Git. - files=$(git ls-files -- '*.c' '*.h' '*.cpp' '*.hpp' '*.cc' '*.hh' '*.cxx' '*.m' '*.mm' '*.inc' '*.java' '*.glsl' \ - ':!:.git/*' ':!:thirdparty/*' ':!:*/thirdparty/*' ':!:platform/android/java/lib/src/com/google/*' \ - ':!:*-so_wrap.*' ':!:tests/python_build/*') -else - # $1 should be a file listing file paths to process. Used in CI. - 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/") -fi - -if [ ! -z "$files" ]; then - clang-format --Wno-error=unknown -i $files -fi - -# Fix copyright headers, but not all files get them. -for f in $files; do - if [[ "$f" == *"inc" && "$f" != *"compat.inc" ]]; then - continue - elif [[ "$f" == *"glsl" ]]; then - continue - elif [[ "$f" == "platform/android/java/lib/src/org/godotengine/godot/gl/GLSurfaceView"* ]]; then - continue - elif [[ "$f" == "platform/android/java/lib/src/org/godotengine/godot/gl/EGLLogWrapper"* ]]; then - continue - elif [[ "$f" == "platform/android/java/lib/src/org/godotengine/godot/utils/ProcessPhoenix"* ]]; then - continue - fi - - python misc/scripts/copyright_headers.py "$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-format 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 new file mode 100644 index 0000000000..de414bbe30 --- /dev/null +++ b/misc/scripts/dotnet_format.py @@ -0,0 +1,30 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +import glob +import os +import sys + +# Create dummy generated files. +for path in [ + "modules/mono/SdkPackageVersions.props", +]: + os.makedirs(os.path.dirname(path), exist_ok=True) + with open(path, "w") as f: + f.write("<Project />") + +# Avoid importing GeneratedIncludes.props. +os.environ["GodotSkipGenerated"] = "true" + +# Match all the input files to their respective C# project. +input_files = [os.path.normpath(x) for x in sys.argv] +projects = { + path: [f for f in sys.argv if os.path.commonpath([f, path]) == path] + for path in [os.path.dirname(f) for f in glob.glob("**/*.csproj", recursive=True)] +} + +# Run dotnet format on all projects with more than 0 modified files. +for path, files in projects.items(): + if len(files) > 0: + command = f"dotnet format {path} --include {' '.join(files)}" + os.system(command) diff --git a/misc/scripts/dotnet_format.sh b/misc/scripts/dotnet_format.sh deleted file mode 100755 index e2b4ba5e43..0000000000 --- a/misc/scripts/dotnet_format.sh +++ /dev/null @@ -1,37 +0,0 @@ -#!/usr/bin/env bash - -# This script runs dotnet format on all relevant files in the repo. -# This is the primary script responsible for fixing style violations in C# files. - -set -uo pipefail - -# Create dummy generated files. -echo "<Project />" > modules/mono/SdkPackageVersions.props -mkdir -p modules/mono/glue/GodotSharp/GodotSharp/Generated -echo "<Project />" > modules/mono/glue/GodotSharp/GodotSharp/Generated/GeneratedIncludes.props -mkdir -p modules/mono/glue/GodotSharp/GodotSharpEditor/Generated -echo "<Project />" > modules/mono/glue/GodotSharp/GodotSharpEditor/Generated/GeneratedIncludes.props - -# Loops through all C# projects tracked by Git. -git ls-files -- '*.csproj' \ - ':!:.git/*' ':!:thirdparty/*' ':!:platform/android/java/lib/src/com/google/*' ':!:*-so_wrap.*' | -while read -r f; do - # Run dotnet format. - dotnet format "$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 dotnet format 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/install_d3d12_sdk_windows.py b/misc/scripts/install_d3d12_sdk_windows.py index 8cfa1d399b..6dd0818b97 100644 --- a/misc/scripts/install_d3d12_sdk_windows.py +++ b/misc/scripts/install_d3d12_sdk_windows.py @@ -3,6 +3,7 @@ import os import urllib.request import shutil +import subprocess # Base Godot dependencies path # If cross-compiling (no LOCALAPPDATA), we install in `bin` @@ -18,8 +19,8 @@ dxc_filename = "dxc_2023_08_14.zip" dxc_archive = os.path.join(deps_folder, dxc_filename) dxc_folder = os.path.join(deps_folder, "dxc") # Mesa NIR -mesa_version = "23.1.0-devel" -mesa_filename = "godot-nir-23.1.0-1-devel.zip" +mesa_version = "23.1.9" +mesa_filename = "godot-nir-23.1.9.zip" mesa_archive = os.path.join(deps_folder, mesa_filename) mesa_folder = os.path.join(deps_folder, "mesa") # WinPixEventRuntime @@ -70,6 +71,16 @@ os.remove(mesa_archive) print(f"Mesa NIR {mesa_filename} installed successfully.\n") # WinPixEventRuntime + +# MinGW needs DLLs converted with dlltool. +# We rely on finding gendef/dlltool to detect if we have MinGW. +# Check existence of needed tools for generating mingw library. +gendef = shutil.which("gendef") or "" +dlltool = shutil.which("dlltool") or "" +if dlltool == "": + dlltool = shutil.which("x86_64-w64-mingw32-dlltool") or "" +has_mingw = gendef != "" and dlltool != "" + print("[3/4] WinPixEventRuntime") if os.path.isfile(pix_archive): os.remove(pix_archive) @@ -81,6 +92,23 @@ if os.path.exists(pix_folder): print(f"Extracting WinPixEventRuntime {pix_version} to {pix_folder} ...") shutil.unpack_archive(pix_archive, pix_folder, "zip") os.remove(pix_archive) +if has_mingw: + print("Adapting WinPixEventRuntime to also support MinGW alongside MSVC.") + cwd = os.getcwd() + os.chdir(pix_folder) + subprocess.run([gendef, "./bin/x64/WinPixEventRuntime.dll"]) + subprocess.run( + [dlltool] + + "--machine i386:x86-64 --no-leading-underscore -d WinPixEventRuntime.def -D WinPixEventRuntime.dll -l ./bin/x64/libWinPixEventRuntime.a".split() + ) + subprocess.run([gendef, "./bin/ARM64/WinPixEventRuntime.dll"]) + subprocess.run( + [dlltool] + + "--machine arm64 --no-leading-underscore -d WinPixEventRuntime.def -D WinPixEventRuntime.dll -l ./bin/ARM64/libWinPixEventRuntime.a".split() + ) + os.chdir(cwd) +else: + print("MinGW wasn't found, so only MSVC support is provided for WinPixEventRuntime.") print(f"WinPixEventRuntime {pix_version} installed successfully.\n") # DirectX 12 Agility SDK @@ -100,5 +128,5 @@ os.remove(agility_sdk_archive) print(f"DirectX 12 Agility SDK {agility_sdk_version} installed successfully.\n") # Complete message -print(f"All Direct3D 12 SDK components were installed to {deps_folder} successfully!") +print(f'All Direct3D 12 SDK components were installed to "{deps_folder}" successfully!') print('You can now build Godot with Direct3D 12 support enabled by running "scons d3d12=yes".') |