Skip the runtime shader step in make_game.py when the release does not carry build_shaders.py, so a player's update compiles again.

The launcher release carries the runtime's shader headers built and none of the tools that build them, and
make_game.py's compile step imported build_shaders unconditionally: every update to the 0.7.0 build stopped at
"Compile Changed Files" with ModuleNotFoundError. The import is now tried, and without it the step that rebuilds stale
headers is left out, as its comment intended. A launcher test checks that every tool make_game.py imports is in the
launcher release unless the import is guarded or only runs on Linux.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
chrg6
2026-11-10 07:44:54 -05:00
parent d6b4eab004
commit f747c4e43d
2 changed files with 30 additions and 3 deletions

View File

@@ -1091,6 +1091,30 @@ class PromptArtTest(Tmp):
for tools in (make_launcher.TOOLS, make_kit.TOOLS):
self.assertLessEqual(local | {'pad_prompts.py'}, set(tools))
def test_launcher_release_carries_what_make_game_imports(self):
"""Every tool make_game.py imports is in the launcher release, unless the import sits in a try that catches
ImportError (build_shaders: a source checkout's step the release's prebuilt headers do not need) or only runs
on Linux (build_game, whose kit carries it). An import that is neither stopped every player's update at its
compile step."""
import ast
import make_launcher
tree = ast.parse((ROOT / 'tools' / 'make_game.py').read_text(encoding='utf-8'))
guarded = set()
for node in ast.walk(tree):
if isinstance(node, ast.Try) and any(
isinstance(h.type, ast.Name) and h.type.id in ('ImportError', 'ModuleNotFoundError')
for h in node.handlers):
for inner in node.body:
guarded |= {id(n) for n in ast.walk(inner)}
needed = set()
for node in ast.walk(tree):
names = [a.name for a in node.names] if isinstance(node, ast.Import) else \
[node.module] if isinstance(node, ast.ImportFrom) and node.module else []
for root in (n.split('.')[0] for n in names):
if (ROOT / 'tools' / f'{root}.py').is_file() and id(node) not in guarded and root != 'build_game':
needed.add(f'{root}.py')
self.assertLessEqual(needed, set(make_launcher.TOOLS))
# ---------------------------------------------------------------- make_game.py

View File

@@ -1225,9 +1225,12 @@ def step_compile(out, cache_dir, msys, jobs, romfs_job=None, update=False):
rt = KIT / 'runtime'
# The runtime's own shaders are in the repository as source only: from a source checkout their headers are not
# there until they are built, and every runtime file that includes one would fail to compile. A kit carries them
# built, so nothing is stale there and no shader compiler is looked for.
import build_shaders
stale = build_shaders.stale(rt)
# built and does not carry tools/build_shaders.py (nor the compilers it calls), so a kit build skips this step.
try:
import build_shaders
except ModuleNotFoundError:
build_shaders = None
stale = build_shaders.stale(rt) if build_shaders else []
if stale:
say(f' compiling {len(stale)} of the runtime\'s own shaders (runtime/*_spv.h)')
build_shaders.build(rt, stale)