From 48d1a6d3a09bc9bb1781d7c6e15303da3ce98329 Mon Sep 17 00:00:00 2001 From: Wellington Dias Date: Fri, 30 Oct 2026 14:56:25 -0300 Subject: [PATCH] Build the release from either game version's generated C, so a checkout with only 1.4.3 can make it. make_release.py and make_release_linux.py built the runtime library and the --prove build from generated/v121 alone. The library reads only what both versions' layout.h share (MOD_COUNT, MOD_MAIN_BASE), so both scripts now take generated/v121, else generated/v143, pass its --version, and name extract.py and gen.py when neither exists. --- tools/make_release.py | 34 ++++++++++++++++++++++++---------- tools/make_release_linux.py | 19 ++++++++++++------- 2 files changed, 36 insertions(+), 17 deletions(-) diff --git a/tools/make_release.py b/tools/make_release.py index 4489c8d8..17845e08 100644 --- a/tools/make_release.py +++ b/tools/make_release.py @@ -17,9 +17,12 @@ cached in toolchain/release-dl/ and checked against the sha256 in PINS; a mismat VERSION the repository's VERSION plus the commit, 0.1.0+973c626; the installer's release string TotK-Setup.exe installer/launcher/launcher.c built with llvm/ (-mwindows): starts python/pythonw.exe -m installer.gui ---prove compiles generated/v121 and links build/release-check/totk.exe with nothing but the folder's python/, llvm/, -runtime/ and bin/ (PATH holds the Windows system directory and those), then runs the four probes there. It needs a -generated/v121 and build/extracted/v121 from the usual game build (they are read, nothing is written to them). +--prove compiles the generated C and links build/release-check/totk.exe with nothing but the folder's python/, llvm/, +runtime/ and bin/ (PATH holds the Windows system directory and those), then runs the four probes there. + +Both need one game version extracted and lifted first (tools/extract.py, recomp/gen.py): generated/v121 or, without +it, generated/v143, and for --prove its build/extracted/ (they are read, nothing is written to them). The +runtime library reads only what both versions' layout.h share (MOD_COUNT, MOD_MAIN_BASE), so either serves. The folder contains nothing derived from the game: check_content runs over it before the script finishes. Then the folder's own python runs a check-only installer pass (no game files: it must get through the release, toolchain and host @@ -328,11 +331,21 @@ def collect_licenses(out): # ---- runtime/, recomp/, tools/, data/ --------------------------------------------------------------------------------- +def lifted_version(): + """The game version whose generated C the runtime library and --prove build against: v121, else v143.""" + for version in ('v121', 'v143'): + if (MAIN_ROOT / 'generated' / version / 'layout.json').is_file(): + return version + sys.exit('neither generated/v121 nor generated/v143 exists: extract a game version and lift it first ' + '(tools/extract.py, recomp/gen.py; docs/building.md)') + + def runtime_lib(out, llvm): """Build libtotkrt.a with the folder's llvm/ and copy it, the headers and the install-side sources into runtime/.""" build = MAIN_ROOT / 'build' / 'release-check' / 'rtlib' - gen = MAIN_ROOT / 'generated' / 'v121' - run([sys.executable, ROOT / 'tools' / 'build_game.py', '--make-runtime-lib', '--toolchain', llvm, + version = lifted_version() + gen = MAIN_ROOT / 'generated' / version + run([sys.executable, ROOT / 'tools' / 'build_game.py', '--make-runtime-lib', '--toolchain', llvm, '--version', version, '--deps', out / 'runtime' / 'deps', '--ninja', out / 'bin' / 'ninja.exe', '--gen', gen, '--out', build], env=clean_env(llvm / 'bin', out / 'bin')) rt = out / 'runtime' @@ -464,17 +477,18 @@ def write_zip(out, path): def prove(out): - """Compile generated/v121 and link totk.exe with the folder's tools only, then run the probes next to it.""" + """Compile the generated C and link totk.exe with the folder's tools only, then run the probes next to it.""" out = out.resolve() - gen = MAIN_ROOT / 'generated' / 'v121' - ext = MAIN_ROOT / 'build' / 'extracted' / 'v121' + version = lifted_version() + gen = MAIN_ROOT / 'generated' / version + ext = MAIN_ROOT / 'build' / 'extracted' / version chk = MAIN_ROOT / 'build' / 'release-check' env = clean_env(out / 'python', out / 'llvm' / 'bin', out / 'bin') t0 = time.time() run([out / 'python' / 'python.exe', out / 'tools' / 'build_game.py', '--toolchain', out / 'llvm', '--deps', out / 'runtime' / 'deps', '--runtime', out / 'runtime', '--runtime-lib', out / 'runtime' / 'libtotkrt.a', - '--ninja', out / 'bin' / 'ninja.exe', '--gen', gen, '--out', chk, '--exefs', ext / 'exefs', '--romfs', ext / 'romfs', - '--profile', chk / 'profile'], env=env) + '--ninja', out / 'bin' / 'ninja.exe', '--version', version, '--gen', gen, '--out', chk, '--exefs', ext / 'exefs', + '--romfs', ext / 'romfs', '--profile', chk / 'profile'], env=env) print(f'prove: build {time.time() - t0:.0f} s') for dll in ('SDL3.dll', 'libopus-0.dll'): shutil.copy2(out / 'bin' / dll, chk / dll) diff --git a/tools/make_release_linux.py b/tools/make_release_linux.py index b44267ea..a4a39501 100644 --- a/tools/make_release_linux.py +++ b/tools/make_release_linux.py @@ -22,7 +22,8 @@ the .NET 10 SDK and Python 3.12+ with Pillow (.venv). The folder holds: AppRun, totk-setup.desktop, totk-setup.png the AppImage entry: python/bin/python3 -m installer.gui --appimage packs the folder with appimagetool and the static type-2 runtime (no libfuse2 on the host). --prove compiles -generated/v121 and links build/release-linux-check/totk with the folder's tools only, then runs the probes beside it. +the generated C and links build/release-linux-check/totk with the folder's tools only, then runs the probes beside it. +Like tools/make_release.py, both need one game version extracted and lifted first (generated/v121, else v143). The folder contains nothing derived from the game: check_content runs over it before the script finishes, then the folder's own python runs a check-only installer pass and the window's --selftest. @@ -198,8 +199,10 @@ def build_bin(out, llvm, sysroot): def runtime_lib(out, llvm, sysroot): build = CHECK / 'rtlib' shutil.rmtree(build, ignore_errors=True) + version = mr.lifted_version() run([sys.executable, ROOT / 'tools' / 'build_game.py', '--make-runtime-lib', '--toolchain', llvm, '--sysroot', sysroot, - '--deps', out / 'runtime' / 'deps', '--ninja', out / 'bin' / 'ninja', '--out', build]) + '--deps', out / 'runtime' / 'deps', '--ninja', out / 'bin' / 'ninja', '--version', version, + '--gen', MAIN_ROOT / 'generated' / version, '--out', build]) rt = out / 'runtime' shutil.copy2(build / 'libtotkrt.a', rt / 'libtotkrt.a') for p in sorted((ROOT / 'runtime').rglob('*')): @@ -428,17 +431,19 @@ def check_bundle(out): def prove(out): - """Compile generated/v121 and link totk with the folder's tools only, then run the probes beside it.""" + """Compile the generated C and link totk with the folder's tools only, then run the probes beside it.""" out = out.resolve() - gen = MAIN_ROOT / 'generated' / 'v121' - ext = MAIN_ROOT / 'build' / 'extracted' / 'v121' + version = mr.lifted_version() + gen = MAIN_ROOT / 'generated' / version + ext = MAIN_ROOT / 'build' / 'extracted' / version chk = CHECK / 'game' env = dict(os.environ, PATH=os.pathsep.join([str(out / 'llvm' / 'bin'), str(out / 'bin'), '/usr/bin', '/bin'])) t0 = time.time() run([out / 'python' / 'bin' / 'python3', out / 'tools' / 'build_game.py', '--toolchain', out / 'llvm', '--sysroot', out / 'llvm' / 'sysroot', '--deps', out / 'runtime' / 'deps', '--runtime', out / 'runtime', - '--runtime-lib', out / 'runtime' / 'libtotkrt.a', '--ninja', out / 'bin' / 'ninja', '--gen', gen, '--out', chk, - '--exefs', ext / 'exefs', '--romfs', ext / 'romfs', '--profile', chk / 'profile'], env=env) + '--runtime-lib', out / 'runtime' / 'libtotkrt.a', '--ninja', out / 'bin' / 'ninja', '--version', version, + '--gen', gen, '--out', chk, '--exefs', ext / 'exefs', '--romfs', ext / 'romfs', '--profile', chk / 'profile'], + env=env) print(f'prove: build {time.time() - t0:.0f} s') shutil.copy2(out / 'bin' / 'libSDL3.so.0', chk / 'libSDL3.so.0') needed = subprocess.run(['readelf', '-d', str(chk / 'totk')], capture_output=True, text=True).stdout