diff --git a/.github/actions/godot-build/action.yml b/.github/actions/godot-build/action.yml index 5ed64e7de260..72c1cea3304d 100644 --- a/.github/actions/godot-build/action.yml +++ b/.github/actions/godot-build/action.yml @@ -20,7 +20,9 @@ inputs: default: "${{ github.workspace }}/.scons-cache/" scons-cache-limit: description: The scons cache size limit. - default: 4096 + # actions/cache has 10 GiB limit, and GitHub runners have a 14 GiB disk. + # Limit to 7 GiB to avoid having the extracted cache fill the disk. + default: 7168 runs: using: "composite" steps: diff --git a/.github/actions/godot-cache/action.yml b/.github/actions/godot-cache-restore/action.yml similarity index 77% rename from .github/actions/godot-cache/action.yml rename to .github/actions/godot-cache-restore/action.yml index e54e6064a73a..614a98330d47 100644 --- a/.github/actions/godot-cache/action.yml +++ b/.github/actions/godot-cache-restore/action.yml @@ -1,5 +1,5 @@ -name: Setup Godot build cache -description: Setup Godot build cache. +name: Restore Godot build cache +description: Restore Godot build cache. inputs: cache-name: description: The cache base name (job name by default). @@ -10,9 +10,8 @@ inputs: runs: using: "composite" steps: - # Upload cache on completion and check it out now - - name: Load .scons_cache directory - uses: actions/cache@v4 + - name: Restore .scons_cache directory + uses: actions/cache/restore@v4 with: path: ${{inputs.scons-cache}} key: ${{inputs.cache-name}}-${{env.GODOT_BASE_BRANCH}}-${{github.ref}}-${{github.sha}} diff --git a/.github/actions/godot-cache-save/action.yml b/.github/actions/godot-cache-save/action.yml new file mode 100644 index 000000000000..bb3f18ad85a1 --- /dev/null +++ b/.github/actions/godot-cache-save/action.yml @@ -0,0 +1,17 @@ +name: Save Godot build cache +description: Save Godot build cache. +inputs: + cache-name: + description: The cache base name (job name by default). + default: "${{github.job}}" + scons-cache: + description: The scons cache path. + default: "${{github.workspace}}/.scons-cache/" +runs: + using: "composite" + steps: + - name: Save .scons_cache directory + uses: actions/cache/save@v4 + with: + path: ${{inputs.scons-cache}} + key: ${{inputs.cache-name}}-${{env.GODOT_BASE_BRANCH}}-${{github.ref}}-${{github.sha}} diff --git a/.github/actions/godot-deps/action.yml b/.github/actions/godot-deps/action.yml index ce5a6ee2c0ff..cac72c436ed3 100644 --- a/.github/actions/godot-deps/action.yml +++ b/.github/actions/godot-deps/action.yml @@ -23,5 +23,5 @@ runs: shell: bash run: | python -c "import sys; print(sys.version)" - python -m pip install scons + python -m pip install scons==4.7.0 scons --version diff --git a/.github/workflows/android_builds.yml b/.github/workflows/android_builds.yml index ab0f9f934bb0..2ba207677fb5 100644 --- a/.github/workflows/android_builds.yml +++ b/.github/workflows/android_builds.yml @@ -1,8 +1,10 @@ name: 🤖 Android Builds -on: [push, pull_request] +on: + workflow_call: # Global Settings env: + # Only used for the cache key. Increment version to force clean build. GODOT_BASE_BRANCH: 3.4 SCONSFLAGS: verbose=yes warnings=all werror=yes debug_symbols=no @@ -12,28 +14,20 @@ concurrency: jobs: android-template: - runs-on: "ubuntu-20.04" - + runs-on: "ubuntu-24.04" name: Template (target=release, tools=no) steps: - uses: actions/checkout@v4 - # Azure repositories are not reliable, we need to prevent azure giving us packages. - - name: Make apt sources.list use the default Ubuntu repositories - run: | - sudo rm -f /etc/apt/sources.list.d/* - sudo cp -f misc/ci/sources.list /etc/apt/sources.list - sudo apt-get update - - name: Set up Java 11 uses: actions/setup-java@v4 with: distribution: temurin java-version: 11 - - name: Setup Godot build cache - uses: ./.github/actions/godot-cache + - name: Restore Godot build cache + uses: ./.github/actions/godot-cache-restore continue-on-error: true - name: Setup python and scons @@ -55,6 +49,10 @@ jobs: target: release tools: false + - name: Save Godot build cache + uses: ./.github/actions/godot-cache-save + continue-on-error: true + - name: Generate Godot templates run: | cd platform/android/java diff --git a/.github/workflows/ios_builds.yml b/.github/workflows/ios_builds.yml index 8fe8eadae929..da0fc7c59615 100644 --- a/.github/workflows/ios_builds.yml +++ b/.github/workflows/ios_builds.yml @@ -1,8 +1,10 @@ name: 🍏 iOS Builds -on: [push, pull_request] +on: + workflow_call: # Global Settings env: + # Only used for the cache key. Increment version to force clean build. GODOT_BASE_BRANCH: 3.4 SCONSFLAGS: verbose=yes warnings=all werror=yes debug_symbols=no @@ -18,14 +20,14 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Setup Godot build cache - uses: ./.github/actions/godot-cache + - name: Restore Godot build cache + uses: ./.github/actions/godot-cache-restore continue-on-error: true - name: Setup python and scons uses: ./.github/actions/godot-deps - - name: Compilation (armv7) + - name: Compilation (arm64v8) uses: ./.github/actions/godot-build with: sconsflags: ${{ env.SCONSFLAGS }} @@ -33,5 +35,9 @@ jobs: target: release tools: false + - name: Save Godot build cache + uses: ./.github/actions/godot-cache-save + continue-on-error: true + - name: Upload artifact uses: ./.github/actions/upload-artifact diff --git a/.github/workflows/javascript_builds.yml b/.github/workflows/javascript_builds.yml index 9c92f3f5f08c..afdf7a077aea 100644 --- a/.github/workflows/javascript_builds.yml +++ b/.github/workflows/javascript_builds.yml @@ -1,8 +1,10 @@ name: 🌐 JavaScript Builds -on: [push, pull_request] +on: + workflow_call: # Global Settings env: + # Only used for the cache key. Increment version to force clean build. GODOT_BASE_BRANCH: 3.4 SCONSFLAGS: verbose=yes warnings=all werror=yes debug_symbols=no EM_VERSION: 2.0.25 @@ -14,32 +16,25 @@ concurrency: jobs: javascript-template: - runs-on: "ubuntu-20.04" + runs-on: "ubuntu-24.04" name: Template (target=release, tools=no) steps: - uses: actions/checkout@v4 - # Additional cache for Emscripten generated system libraries - - name: Load Emscripten cache - id: javascript-template-emscripten-cache - uses: actions/cache@v4 - with: - path: ${{env.EM_CACHE_FOLDER}} - key: ${{env.EM_VERSION}}-${{github.job}} - - name: Set up Emscripten latest uses: mymindstorm/setup-emsdk@v14 with: version: ${{env.EM_VERSION}} actions-cache-folder: ${{env.EM_CACHE_FOLDER}} + cache-key: emsdk-${{ matrix.cache-name }}-${{env.GODOT_BASE_BRANCH}}-${{github.ref}}-${{github.sha}} - name: Verify Emscripten setup run: | emcc -v - - name: Setup Godot build cache - uses: ./.github/actions/godot-cache + - name: Restore Godot build cache + uses: ./.github/actions/godot-cache-restore continue-on-error: true - name: Setup python and scons @@ -53,5 +48,9 @@ jobs: target: release tools: false + - name: Save Godot build cache + uses: ./.github/actions/godot-cache-save + continue-on-error: true + - name: Upload artifact uses: ./.github/actions/upload-artifact diff --git a/.github/workflows/linux_builds.yml b/.github/workflows/linux_builds.yml index a9fc2091f01d..38719cb1600f 100644 --- a/.github/workflows/linux_builds.yml +++ b/.github/workflows/linux_builds.yml @@ -1,8 +1,10 @@ name: 🐧 Linux Builds -on: [push, pull_request] +on: + workflow_call: # Global Settings env: + # Only used for the cache key. Increment version to force clean build. GODOT_BASE_BRANCH: 3.4 SCONSFLAGS: verbose=yes warnings=all werror=yes @@ -12,7 +14,8 @@ concurrency: jobs: build-linux: - runs-on: "ubuntu-20.04" + # Stay one LTS before latest to increase portability of Linux artifacts. + runs-on: "ubuntu-22.04" name: ${{ matrix.name }} strategy: fail-fast: false @@ -27,11 +30,11 @@ jobs: build-mono: true artifact: true - - name: Editor and sanitizers (target=debug, tools=yes, use_asan=yes, use_ubsan=yes) + - name: Editor and sanitizers (target=debug, tools=yes, use_asan=yes, use_ubsan=yes, linker=gold) cache-name: linux-editor-sanitizers target: debug tools: true - sconsflags: use_asan=yes use_ubsan=yes + sconsflags: use_asan=yes use_ubsan=yes linker=gold test: true bin: "./bin/godot.x11.tools.64s" build-mono: false @@ -52,17 +55,22 @@ jobs: - name: Linux dependencies shell: bash run: | - # Azure repositories are not reliable, we need to prevent azure giving us packages. - sudo rm -f /etc/apt/sources.list.d/* - sudo cp -f misc/ci/sources.list /etc/apt/sources.list + # Azure repositories are flaky, remove them. + sudo rm -f /etc/apt/sources.list.d/{azure,microsoft}* sudo apt-get update - # The actual dependencies - sudo apt-get install build-essential pkg-config libx11-dev libxcursor-dev \ - libxinerama-dev libgl1-mesa-dev libglu-dev libasound2-dev libpulse-dev \ - libdbus-1-dev libudev-dev libxi-dev libxrandr-dev yasm xvfb wget unzip + # The actual dependencies. + sudo apt-get install --no-install-recommends build-essential pkg-config libx11-dev \ + libxcursor-dev libxinerama-dev libgl1-mesa-dev libglu-dev libasound2-dev \ + libpulse-dev libdbus-1-dev libudev-dev libxi-dev libxrandr-dev yasm xvfb wget unzip - - name: Setup Godot build cache - uses: ./.github/actions/godot-cache + - name: Free disk space on runner + run: | + echo "Disk usage before:" && df -h + sudo rm -rf /usr/local/lib/android + echo "Disk usage after:" && df -h + + - name: Restore Godot build cache + uses: ./.github/actions/godot-cache-restore with: cache-name: ${{ matrix.cache-name }} continue-on-error: true @@ -70,6 +78,9 @@ jobs: - name: Setup python and scons uses: ./.github/actions/godot-deps + - name: Setup GCC problem matcher + uses: ammaraskar/gcc-problem-matcher@master + - name: Compilation uses: ./.github/actions/godot-build with: @@ -78,6 +89,12 @@ jobs: target: ${{ matrix.target }} tools: ${{ matrix.tools }} + - name: Save Godot build cache + uses: ./.github/actions/godot-cache-save + with: + cache-name: ${{ matrix.cache-name }} + continue-on-error: true + # Generate mono glue - name: Generate Mono glue code if: ${{ matrix.build-mono }} @@ -129,6 +146,7 @@ jobs: if: ${{ matrix.artifact }} run: | strip bin/godot.* + chmod +x bin/godot.* - name: Upload artifact uses: ./.github/actions/upload-artifact diff --git a/.github/workflows/macos_builds.yml b/.github/workflows/macos_builds.yml index a16e455662d5..b9a24a56391d 100644 --- a/.github/workflows/macos_builds.yml +++ b/.github/workflows/macos_builds.yml @@ -1,8 +1,10 @@ name: 🍎 macOS Builds -on: [push, pull_request] +on: + workflow_call: # Global Settings env: + # Only used for the cache key. Increment version to force clean build. GODOT_BASE_BRANCH: 3.4 SCONSFLAGS: verbose=yes warnings=all werror=yes debug_symbols=no @@ -32,8 +34,8 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Setup Godot build cache - uses: ./.github/actions/godot-cache + - name: Restore Godot build cache + uses: ./.github/actions/godot-cache-restore with: cache-name: ${{ matrix.cache-name }} continue-on-error: true @@ -49,6 +51,17 @@ jobs: target: ${{ matrix.target }} tools: ${{ matrix.tools }} + - name: Save Godot build cache + uses: ./.github/actions/godot-cache-save + with: + cache-name: ${{ matrix.cache-name }} + continue-on-error: true + + - name: Prepare artifact + run: | + strip bin/godot.* + chmod +x bin/godot.* + - name: Upload artifact uses: ./.github/actions/upload-artifact with: diff --git a/.github/workflows/runner.yml b/.github/workflows/runner.yml new file mode 100644 index 000000000000..1981da5b8f09 --- /dev/null +++ b/.github/workflows/runner.yml @@ -0,0 +1,46 @@ +name: 🔗 GHA +on: [push, pull_request] + +concurrency: + group: ci-${{github.actor}}-${{github.head_ref || github.run_number}}-${{github.ref}}-runner + cancel-in-progress: true + +jobs: + static-checks: + name: 📊 Static + uses: ./.github/workflows/static_checks.yml + + android-build: + name: 🤖 Android + needs: static-checks + uses: ./.github/workflows/android_builds.yml + + ios-build: + name: 🍏 iOS + needs: static-checks + uses: ./.github/workflows/ios_builds.yml + + javascript-build: + name: 🌐 JavaScript + needs: static-checks + uses: ./.github/workflows/javascript_builds.yml + + linux-build: + name: 🐧 Linux + needs: static-checks + uses: ./.github/workflows/linux_builds.yml + + macos-build: + name: 🍎 macOS + needs: static-checks + uses: ./.github/workflows/macos_builds.yml + + server-build: + name: ☁ Server + needs: static-checks + uses: ./.github/workflows/server_builds.yml + + windows-build: + name: 🏁 Windows + needs: static-checks + uses: ./.github/workflows/windows_builds.yml diff --git a/.github/workflows/server_builds.yml b/.github/workflows/server_builds.yml index f8784dc1321b..6337d878e813 100644 --- a/.github/workflows/server_builds.yml +++ b/.github/workflows/server_builds.yml @@ -1,8 +1,10 @@ name: ☁ Server Builds -on: [push, pull_request] +on: + workflow_call: # Global Settings env: + # Only used for the cache key. Increment version to force clean build. GODOT_BASE_BRANCH: 3.4 SCONSFLAGS: verbose=yes warnings=all werror=yes debug_symbols=no module_mono_enabled=yes mono_static=yes mono_glue=no @@ -12,7 +14,8 @@ concurrency: jobs: build-server: - runs-on: "ubuntu-20.04" + # Stay one LTS before latest to increase portability of Linux artifacts. + runs-on: "ubuntu-22.04" name: ${{ matrix.name }} strategy: fail-fast: false @@ -34,17 +37,16 @@ jobs: - name: Linux dependencies shell: bash run: | - # Azure repositories are not reliable, we need to prevent azure giving us packages. - sudo rm -f /etc/apt/sources.list.d/* - sudo cp -f misc/ci/sources.list /etc/apt/sources.list + # Azure repositories are flaky, remove them. + sudo rm -f /etc/apt/sources.list.d/{azure,microsoft}* sudo apt-get update - # The actual dependencies - sudo apt-get install build-essential pkg-config libx11-dev libxcursor-dev \ - libxinerama-dev libgl1-mesa-dev libglu-dev libasound2-dev libpulse-dev \ - libdbus-1-dev libudev-dev libxi-dev libxrandr-dev yasm xvfb wget unzip + # The actual dependencies. + sudo apt-get install --no-install-recommends build-essential pkg-config libx11-dev \ + libxcursor-dev libxinerama-dev libgl1-mesa-dev libglu-dev libasound2-dev \ + libpulse-dev libdbus-1-dev libudev-dev libxi-dev libxrandr-dev yasm xvfb wget unzip - - name: Setup Godot build cache - uses: ./.github/actions/godot-cache + - name: Restore Godot build cache + uses: ./.github/actions/godot-cache-restore with: cache-name: ${{ matrix.cache-name }} continue-on-error: true @@ -59,3 +61,9 @@ jobs: platform: server target: ${{ matrix.target }} tools: ${{ matrix.tools }} + + - name: Save Godot build cache + uses: ./.github/actions/godot-cache-save + with: + cache-name: ${{ matrix.cache-name }} + continue-on-error: true diff --git a/.github/workflows/static_checks.yml b/.github/workflows/static_checks.yml index 956442a0e6e4..4d4f949e3eb7 100644 --- a/.github/workflows/static_checks.yml +++ b/.github/workflows/static_checks.yml @@ -1,38 +1,38 @@ name: 📊 Static Checks -on: [push, pull_request] +on: + workflow_call: + +concurrency: + group: ci-${{github.actor}}-${{github.head_ref || github.run_number}}-${{github.ref}}-static + cancel-in-progress: true jobs: static-checks: name: Static Checks (clang-format, black format, file format, documentation checks) - runs-on: ubuntu-20.04 + runs-on: "ubuntu-24.04" steps: - name: Checkout uses: actions/checkout@v4 - # Azure repositories are not reliable, we need to prevent Azure giving us packages. - - name: Make apt sources.list use the default Ubuntu repositories + - name: Install dependencies run: | - sudo rm -f /etc/apt/sources.list.d/* - sudo cp -f misc/ci/sources.list /etc/apt/sources.list - wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - - sudo apt-add-repository "deb http://apt.llvm.org/focal/ llvm-toolchain-focal-13 main" + # Azure repositories are flaky, remove them. + sudo rm -f /etc/apt/sources.list.d/{azure,microsoft}* sudo apt-get update + sudo apt-get install -qq dos2unix libxml2-utils python3-pip moreutils + sudo update-alternatives --remove-all clang-format || true + sudo update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-16 100 + sudo pip3 install black==24.10.0 pygments - - name: Install dependencies + # This needs to happen before Python and npm execution; it must happen before any extra files are written. + - name: .gitignore checks (gitignore_check.sh) run: | - sudo apt-get install -qq dos2unix recode clang-format-13 - sudo update-alternatives --remove-all clang-format - sudo update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-13 100 - sudo pip3 install black==21.10b0 pygments + bash ./misc/scripts/gitignore_check.sh - name: File formatting checks (file_format.sh) run: | bash ./misc/scripts/file_format.sh - - name: Style checks via clang-format (clang_format.sh) - run: | - bash ./misc/scripts/clang_format.sh - - name: Python style checks via black (black_format.sh) run: | bash ./misc/scripts/black_format.sh @@ -44,6 +44,14 @@ jobs: npm run lint npm run docs -- -d dry-run + - name: Class reference schema checks + run: | + xmllint --noout --schema doc/class.xsd doc/classes/*.xml modules/*/doc_classes/*.xml + - name: Documentation checks run: | doc/tools/make_rst.py --dry-run doc/classes modules + + - name: Style checks via clang-format (clang_format.sh) + run: | + bash ./misc/scripts/clang_format.sh diff --git a/.github/workflows/windows_builds.yml b/.github/workflows/windows_builds.yml index 4ee0e73e8d8d..3afa796026b2 100644 --- a/.github/workflows/windows_builds.yml +++ b/.github/workflows/windows_builds.yml @@ -1,9 +1,11 @@ name: 🏁 Windows Builds -on: [push, pull_request] +on: + workflow_call: # Global Settings # SCONS_CACHE for windows must be set in the build environment env: + # Only used for the cache key. Increment version to force clean build. GODOT_BASE_BRANCH: 3.4 SCONSFLAGS: verbose=yes warnings=all werror=yes debug_symbols=no SCONS_CACHE_MSVC_CONFIG: true @@ -35,8 +37,8 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Setup Godot build cache - uses: ./.github/actions/godot-cache + - name: Restore Godot build cache + uses: ./.github/actions/godot-cache-restore with: cache-name: ${{ matrix.cache-name }} continue-on-error: true @@ -44,6 +46,9 @@ jobs: - name: Setup python and scons uses: ./.github/actions/godot-deps + - name: Setup MSVC problem matcher + uses: ammaraskar/msvc-problem-matcher@master + - name: Compilation uses: ./.github/actions/godot-build with: @@ -51,7 +56,16 @@ jobs: platform: windows target: ${{ matrix.target }} tools: ${{ matrix.tools }} - scons-cache-limit: 3072 + + - name: Save Godot build cache + uses: ./.github/actions/godot-cache-save + with: + cache-name: ${{ matrix.cache-name }} + continue-on-error: true + + - name: Prepare artifact + run: | + Remove-Item bin/* -Include *.exp,*.lib,*.pdb -Force - name: Upload artifact uses: ./.github/actions/upload-artifact diff --git a/compat.py b/compat.py index 8fcaa4f7c783..725a47837715 100644 --- a/compat.py +++ b/compat.py @@ -43,7 +43,6 @@ def qualname(obj): # Not properly equivalent to __qualname__ in py3, but it doesn't matter. return obj.__name__ - else: def isbasestring(s): diff --git a/doc/translations/extract.py b/doc/translations/extract.py index 0a63ee258554..71b5e3ef9c0b 100644 --- a/doc/translations/extract.py +++ b/doc/translations/extract.py @@ -45,6 +45,7 @@ sys.modules["_elementtree"] = None import xml.etree.ElementTree as ET + ## override the parser to get the line number class LineNumberingParser(ET.XMLParser): def _start(self, *args, **kwargs): diff --git a/editor/editor_builders.py b/editor/editor_builders.py index ab0b7f74d01f..baddd8f09dd1 100644 --- a/editor/editor_builders.py +++ b/editor/editor_builders.py @@ -3,6 +3,7 @@ All such functions are invoked in a subprocess on Windows to prevent build flakiness. """ + import os import os.path from platform_methods import subprocess_main diff --git a/editor/icons/editor_icons_builders.py b/editor/icons/editor_icons_builders.py index ce6b9a8686ab..dd910a6810b8 100644 --- a/editor/icons/editor_icons_builders.py +++ b/editor/icons/editor_icons_builders.py @@ -3,6 +3,7 @@ All such functions are invoked in a subprocess on Windows to prevent build flakiness. """ + import os from platform_methods import subprocess_main from compat import StringIO diff --git a/gles_builders.py b/gles_builders.py index dda3922ed3fb..367d1a7f9ddf 100644 --- a/gles_builders.py +++ b/gles_builders.py @@ -3,6 +3,7 @@ All such functions are invoked in a subprocess on Windows to prevent build flakiness. """ + from platform_methods import subprocess_main @@ -385,7 +386,7 @@ def build_legacygl_header(filename, include, class_suffix, output_attribs, gles2 x = header_data.enums[xv] bits = 1 amt = len(x) - while 2 ** bits < amt: + while 2**bits < amt: bits += 1 strs = "{" for i in range(amt): diff --git a/main/main_builders.py b/main/main_builders.py index 6e5a5ceede4f..d8334f3b7a58 100644 --- a/main/main_builders.py +++ b/main/main_builders.py @@ -3,6 +3,7 @@ All such functions are invoked in a subprocess on Windows to prevent build flakiness. """ + from platform_methods import subprocess_main from compat import byte_to_str from collections import OrderedDict diff --git a/misc/ci/sources.list b/misc/ci/sources.list deleted file mode 100644 index 4d8f94f35c41..000000000000 --- a/misc/ci/sources.list +++ /dev/null @@ -1,4 +0,0 @@ -deb http://archive.ubuntu.com/ubuntu/ focal main restricted universe multiverse -deb http://archive.ubuntu.com/ubuntu/ focal-updates main restricted universe multiverse -deb http://archive.ubuntu.com/ubuntu/ focal-security main restricted universe multiverse -deb http://archive.ubuntu.com/ubuntu/ focal-backports main restricted universe multiverse diff --git a/misc/scripts/check_ci_log.py b/misc/scripts/check_ci_log.py index 19d0362d6181..006348afc930 100755 --- a/misc/scripts/check_ci_log.py +++ b/misc/scripts/check_ci_log.py @@ -25,6 +25,8 @@ file_contents.find("Program crashed with signal") != -1 or file_contents.find("Dumping the backtrace") != -1 or file_contents.find("Segmentation fault (core dumped)") != -1 + or file_contents.find("Aborted (core dumped)") != -1 + or file_contents.find("terminate called without an active exception") != -1 ): print("FATAL ERROR: Godot has been crashed.") sys.exit(1) diff --git a/misc/scripts/clang_format.sh b/misc/scripts/clang_format.sh index b0020da59701..bd728a6f66c2 100755 --- a/misc/scripts/clang_format.sh +++ b/misc/scripts/clang_format.sh @@ -31,7 +31,11 @@ while IFS= read -rd '' f; do continue 2 elif [[ "$f" == *"theme_data.h" ]]; then continue 2 - elif [[ "$f" == "platform/android/java/lib/src/org/godotengine/godot/input/InputManager"* ]]; then + elif [[ "$f" == "platform/android/java/lib/src/org/godotengine/godot/gl/GLSurfaceView"* ]]; then + continue 2 + elif [[ "$f" == "platform/android/java/lib/src/org/godotengine/godot/gl/EGLLogWrapper"* ]]; then + continue 2 + elif [[ "$f" == "platform/android/java/lib/src/org/godotengine/godot/utils/ProcessPhoenix"* ]]; then continue 2 fi python misc/scripts/copyright_headers.py "$f" diff --git a/misc/scripts/codespell.sh b/misc/scripts/codespell.sh new file mode 100644 index 000000000000..1f84ba123393 --- /dev/null +++ b/misc/scripts/codespell.sh @@ -0,0 +1,5 @@ +#!/bin/sh +SKIP_LIST="./.git,./bin,./thirdparty,*.gen.*,*.po,*.pot,package-lock.json,./core/string/locales.h,./DONORS.md,./misc/dist/linux/org.godotengine.Godot.desktop,./misc/scripts/codespell.sh" +IGNORE_LIST="ba,childs,commiting,complies,curvelinear,doubleclick,expct,fave,findn,gird,inout,leapyear,lod,nd,numer,ois,readded,ro,statics,switchs,te,varius,varn" + +codespell -w -q 3 -S "${SKIP_LIST}" -L "${IGNORE_LIST}" diff --git a/misc/scripts/copyright_headers.py b/misc/scripts/copyright_headers.py index cf3adbfbfaa6..a5e2f0c05dfb 100755 --- a/misc/scripts/copyright_headers.py +++ b/misc/scripts/copyright_headers.py @@ -4,35 +4,35 @@ import sys header = """\ -/*************************************************************************/ -/* $filename */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ +/**************************************************************************/ +/* $filename */ +/**************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/**************************************************************************/ +/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ +/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/**************************************************************************/ """ fname = sys.argv[1] diff --git a/misc/scripts/file_format.sh b/misc/scripts/file_format.sh index 07a9a070f37c..d6c671783782 100755 --- a/misc/scripts/file_format.sh +++ b/misc/scripts/file_format.sh @@ -5,8 +5,8 @@ # run before them. # We need dos2unix and recode. -if [ ! -x "$(command -v dos2unix)" -o ! -x "$(command -v recode)" ]; then - printf "Install 'dos2unix' and 'recode' to use this script.\n" +if [ ! -x "$(command -v dos2unix)" -o ! -x "$(command -v isutf8)" ]; then + printf "Install 'dos2unix' and 'isutf8' (from the moreutils package) to use this script.\n" fi set -uo pipefail @@ -28,7 +28,9 @@ while IFS= read -rd '' f; do continue elif [[ "$f" == *"po" ]]; then continue - elif [[ "$f" == "thirdparty"* ]]; then + elif [[ "$f" == "thirdparty/"* ]]; then + continue + elif [[ "$f" == *"/thirdparty/"* ]]; then continue elif [[ "$f" == "platform/android/java/lib/src/com/google"* ]]; then continue @@ -36,7 +38,7 @@ while IFS= read -rd '' f; do continue fi # Ensure that files are UTF-8 formatted. - recode UTF-8 "$f" 2> /dev/null + isutf8 "$f" >> utf8-validation.txt 2>&1 # Ensure that files have LF line endings and do not contain a BOM. dos2unix "$f" 2> /dev/null # Remove trailing space characters and ensures that files end @@ -48,17 +50,27 @@ done git diff --color > patch.patch -# If no patch has been generated all is OK, clean up, and exit. -if [ ! -s patch.patch ] ; then +# If no UTF-8 violations were collected and no patch has been +# generated all is OK, clean up, and exit. +if [ ! -s utf8-validation.txt ] && [ ! -s patch.patch ] ; then printf "Files in this commit comply with the formatting rules.\n" - rm -f patch.patch + rm -f patch.patch utf8-validation.txt 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 +# Violations detected, notify the user, clean up, and exit. +if [ -s utf8-validation.txt ] +then + printf "\n*** The following files contain invalid UTF-8 character sequences:\n\n" + cat utf8-validation.txt +fi + +if [ -s patch.patch ] +then + printf "\n*** The following differences were found between the code " + printf "and the formatting rules:\n\n" + cat patch.patch +fi +rm -f utf8-validation.txt patch.patch printf "\n*** Aborting, please fix your commit(s) with 'git commit --amend' or 'git rebase -i '\n" -rm -f patch.patch exit 1 diff --git a/misc/scripts/gitignore_check.sh b/misc/scripts/gitignore_check.sh new file mode 100644 index 000000000000..f162e25391b0 --- /dev/null +++ b/misc/scripts/gitignore_check.sh @@ -0,0 +1,26 @@ +set -uo pipefail +shopt -s globstar + +echo -e ".gitignore validation..." + +# Get a list of files that exist in the repo but are ignored. + +# The --verbose flag also includes files un-ignored via ! prefixes. +# We filter those out with a somewhat awkward `awk` directive. + # (Explanation: Split each line by : delimiters, + # see if the actual gitignore line shown in the third field starts with !, + # if it doesn't, print it.) + +# ignorecase for the sake of Windows users. + +output=$(git -c core.ignorecase=true check-ignore --verbose --no-index **/* | \ + awk -F ':' '{ if ($3 !~ /^!/) print $0 }') + +# Then we take this result and return success if it's empty. +if [ -z "$output" ]; then + exit 0 +else + # And print the result if it isn't. + echo "$output" + exit 1 +fi diff --git a/misc/scripts/header_guards.sh b/misc/scripts/header_guards.sh new file mode 100755 index 000000000000..45671fcd0a28 --- /dev/null +++ b/misc/scripts/header_guards.sh @@ -0,0 +1,61 @@ +#!/bin/bash + +if [ ! -f "version.py" ]; then + echo "Warning: This script is intended to be run from the root of the Godot repository." + echo "Some of the paths checks may not work as intended from a different folder." +fi + +for file in $(find -name "thirdparty" -prune -o -name "*.h" -print); do + # Skip *.gen.h and *-so_wrap.h, they're generated. + if [[ "$file" == *".gen.h" || "$file" == *"-so_wrap.h" ]]; then continue; fi + # Has important define before normal header guards. + if [[ "$file" == *"thread.h" || "$file" == *"platform_config.h" ]]; then continue; fi + + bname=$(basename $file .h) + + # Add custom prefix or suffix for generic filenames with a well-defined namespace. + + prefix= + if [[ "$file" == "./modules/gdnative/"*"/register_types.h" ]]; then + module=$(echo $file | sed "s@.*modules/gdnative/\([^/]*\).*@\1@") + prefix="${module^^}_" + elif [[ "$file" == "./modules/"*"/register_types.h" ]]; then + module=$(echo $file | sed "s@.*modules/\([^/]*\).*@\1@") + prefix="${module^^}_" + fi + if [[ "$file" == "./platform/"*"/api/api.h" || "$file" == "./platform/"*"/export/"* ]]; then + platform=$(echo $file | sed "s@.*platform/\([^/]*\).*@\1@") + prefix="${platform^^}_" + fi + if [[ "$file" == "./modules/mono/utils/"* && "$bname" != *"mono"* ]]; then prefix="MONO_"; fi + if [[ "$file" == "./modules/gdnative/include/gdnative/"* ]]; then prefix="GDNATIVE_"; fi + + suffix= + if [[ "$file" == *"ustring.h" ]]; then suffix="_GODOT"; fi + + # ^^ is bash builtin for UPPERCASE. + guard="${prefix}${bname^^}${suffix}_H" + + # Replaces guards to use computed name. + # We also add some \n to make sure there's a proper separation. + sed -i $file -e "0,/ifndef/s/#ifndef.*/\n#ifndef $guard/" + sed -i $file -e "0,/define/s/#define.*/#define $guard\n/" + sed -i $file -e "$ s/#endif.*/\n#endif \/\/ $guard/" + # Removes redundant \n added before, if they weren't needed. + sed -i $file -e "/^$/N;/^\n$/D" +done + +diff=$(git diff --color) + +# If no diff has been generated all is OK, clean up, and exit. +if [ -z "$diff" ] ; then + printf "Files in this commit comply with the header guards formatting rules.\n" + exit 0 +fi + +# A diff has been created, notify the user, clean up, and exit. +printf "\n*** The following differences were found between the code " +printf "and the header guards formatting rules:\n\n" +echo "$diff" +printf "\n*** Aborting, please fix your commit(s) with 'git commit --amend' or 'git rebase -i '\n" +exit 1 diff --git a/modules/denoise/resource_to_cpp.py b/modules/denoise/resource_to_cpp.py index 6c8327735599..307ea0ee7ded 100644 --- a/modules/denoise/resource_to_cpp.py +++ b/modules/denoise/resource_to_cpp.py @@ -19,6 +19,7 @@ import os from array import array + # Generates a C++ file from the specified binary resource file def generate(in_path, out_path): diff --git a/modules/gdnative/gdnative_builders.py b/modules/gdnative/gdnative_builders.py index d44bf452144a..fa9c42239456 100644 --- a/modules/gdnative/gdnative_builders.py +++ b/modules/gdnative/gdnative_builders.py @@ -3,6 +3,7 @@ All such functions are invoked in a subprocess on Windows to prevent build flakiness. """ + import json from platform_methods import subprocess_main diff --git a/platform/osx/platform_osx_builders.py b/platform/osx/platform_osx_builders.py index 953ed479db36..d60f78884a09 100644 --- a/platform/osx/platform_osx_builders.py +++ b/platform/osx/platform_osx_builders.py @@ -3,6 +3,7 @@ All such functions are invoked in a subprocess on Windows to prevent build flakiness. """ + import os from platform_methods import subprocess_main diff --git a/platform/server/detect.py b/platform/server/detect.py index 6fa838df17de..98ecb771ae01 100644 --- a/platform/server/detect.py +++ b/platform/server/detect.py @@ -76,7 +76,7 @@ def configure(env): ## Architecture - is64 = sys.maxsize > 2 ** 32 + is64 = sys.maxsize > 2**32 if env["bits"] == "default": env["bits"] = "64" if is64 else "32" diff --git a/platform/windows/platform_windows_builders.py b/platform/windows/platform_windows_builders.py index 22e33b51b490..0d518e31c437 100644 --- a/platform/windows/platform_windows_builders.py +++ b/platform/windows/platform_windows_builders.py @@ -3,6 +3,7 @@ All such functions are invoked in a subprocess on Windows to prevent build flakiness. """ + import os from platform_methods import subprocess_main diff --git a/platform/x11/platform_x11_builders.py b/platform/x11/platform_x11_builders.py index 5884f8e16118..632bafce020d 100644 --- a/platform/x11/platform_x11_builders.py +++ b/platform/x11/platform_x11_builders.py @@ -3,6 +3,7 @@ All such functions are invoked in a subprocess on Windows to prevent build flakiness. """ + import os from platform_methods import subprocess_main