From ba3906a9d4c5d41e95fdf54ac7ce685358b93e6f Mon Sep 17 00:00:00 2001 From: nikitalita <69168929+nikitalita@users.noreply.github.com> Date: Fri, 3 Jul 2026 19:14:51 -0700 Subject: [PATCH] Exit build with error if we're not on the correct godot branch --- .scripts/rebase_godot.sh | 1 + SCsub | 22 ++++++++++++++++++++++ config.py | 1 + 3 files changed, 24 insertions(+) diff --git a/.scripts/rebase_godot.sh b/.scripts/rebase_godot.sh index 4038336df..2ae358752 100755 --- a/.scripts/rebase_godot.sh +++ b/.scripts/rebase_godot.sh @@ -65,4 +65,5 @@ git push nikitalita $NEW_BRANCH_NAME --set-upstream # change the branch name in .github/workflows/all_builds.yml and the README.md sed_in_place "s/GODOT_MAIN_SYNC_REF: .*/GODOT_MAIN_SYNC_REF: $NEW_BRANCH_NAME/" "$GDRE_PATH/.github/workflows/all_builds.yml" +sed_in_place "s/GODOT_MAIN_SYNC_REF = .*/GODOT_MAIN_SYNC_REF = \"$NEW_BRANCH_NAME\"/" "$GDRE_PATH/SCsub" sed_in_place "s/ @ branch \`.*\`/ @ branch \`$NEW_BRANCH_NAME\`/" "$GDRE_PATH/README.md" diff --git a/SCsub b/SCsub index ce7bd4f6e..6288b28c6 100644 --- a/SCsub +++ b/SCsub @@ -1,7 +1,9 @@ #!/usr/bin/env python +import subprocess from SCons.Script.SConscript import SConsEnvironment import os +import sys from typing import TYPE_CHECKING from build import gdre_icon_builder # pyright: ignore[reportImplicitRelativeImport] @@ -21,6 +23,7 @@ if TYPE_CHECKING: Import("env") Import("env_modules") +GODOT_MAIN_SYNC_REF = "gdre-wb-f964fa714f5" MODULE_DIR = get_module_dir(env) BUILD_DIR = get_build_dir(env) @@ -37,6 +40,25 @@ INCLUDE_DIRS = [ AXML_DEC_INCLUDE_DIR, ] +if not env["ignore_godot_branch_check"]: + ROOT_GODOT_DIR: str = str(env.Dir("#").abspath) + try: + godot_branch: str = subprocess.run( + f"git -C {ROOT_GODOT_DIR} rev-parse --abbrev-ref HEAD", shell=True, capture_output=True, text=True + ).stdout.strip() + if godot_branch != GODOT_MAIN_SYNC_REF: + print( + f""" +************************************************** +Error: Godot repository is not on expected '{GODOT_MAIN_SYNC_REF}' branch, please checkout the correct branch and try again +(set Scons option 'ignore_godot_branch_check' to true to ignore this error and build anyway) +************************************************** +""" + ) + sys.exit(1) + except Exception as e: + print(f"Error running git command: {e}") + env_gdsdecomp = env_modules.Clone() diff --git a/config.py b/config.py index 175dee60d..45e0089f7 100644 --- a/config.py +++ b/config.py @@ -77,6 +77,7 @@ def get_opts(platform): opts = [ BoolVariable("disable_godot_mono_decomp", "Disable Godot Mono Decompilation", False), BoolVariable("disable_gifski", "Disable Gifski", False), + BoolVariable("ignore_godot_branch_check", "Ignore Godot branch check", False), ] if not (platform == "android" or platform == "macos"): opts.append(BoolVariable("use_static_godot_mono_decomp", "Build Godot Mono Decomp library as static", False))