Do not lift again because the RomFS step ran.

A step that runs drops the record of every step after it, and the RomFS
step comes before the lift although the lift reads only the unpacked
ExeFS. An install that was cut short while the image was still being
packed, the lift beside it already done, therefore lifted the whole game
again at the next try. The RomFS step now leaves the lift's record; the
compile and the shaders, which read the image, still follow it.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
chrg6
2026-11-10 15:19:37 -05:00
parent e732173bea
commit d27654ad9b
2 changed files with 40 additions and 2 deletions

View File

@@ -1407,6 +1407,40 @@ class MakeGameTest(Tmp):
steps = json.loads((self.out / 'build-cache' / 'state.json').read_text())['steps']
self.assertEqual(set(steps), {'exefs', 'romfs', 'lift', 'compile'})
def test_a_repeated_romfs_step_does_not_repeat_the_lift(self):
"""An install cut short while the RomFS image was packed, its lift already done: the next run packs the
image again and compiles, but keeps the lift, which reads only the unpacked ExeFS."""
calls = []
def lift(out, cache):
calls.append('lift')
(cache / 'lift').mkdir(exist_ok=True)
(cache / 'lift' / 'layout.json').write_text('[]') # the lifted code is there (make_game.py lift_gone)
def compile_(out, cache, msys, jobs, romfs_job=None, update=False):
calls.append('compile')
if romfs_job:
romfs_job.join()
(out / self.mg.EXE_NAME).write_bytes(b'MZ')
self.assertEqual(self.main_with(self.mg.step_romfs, lift, compile_), 0)
self.assertEqual(calls, ['lift', 'compile'])
state = self.out / 'build-cache' / 'state.json'
st = json.loads(state.read_text())
for step in ('romfs', 'compile'): # as the cut run left it: the image and the compile not finished
del st['steps'][step]
state.write_text(json.dumps(st))
(self.out / 'romfs' / 'romfs.bin').unlink()
self.assertEqual(self.main_with(self.mg.step_romfs, lift, compile_), 0)
self.assertEqual(calls, ['lift', 'compile', 'compile'])
self.assertTrue((self.out / 'romfs' / 'romfs.bin').is_file())
self.assertEqual(set(json.loads(state.read_text())['steps']), {'exefs', 'romfs', 'lift', 'compile'})
# the ExeFS step still makes the lift run again: the lift reads what it writes
st = json.loads(state.read_text())
del st['steps']['exefs']
state.write_text(json.dumps(st))
self.assertEqual(self.main_with(self.mg.step_romfs, lift, compile_), 0)
self.assertEqual(calls, ['lift', 'compile', 'compile', 'lift', 'compile'])
def test_shader_progress_reaches_the_launcher(self):
"""The shaders step turns nx2navi.exe's counts into progress (translation the first half of the bar, the
driver build the second), sends one every few seconds while nothing is printed, says when the counts stop

View File

@@ -92,6 +92,10 @@ STEPS = ('exefs', 'romfs', 'lift', 'compile', 'shaders', 'prompts', 'scan')
# Steps whose key names every input they read rather than the step before them: a step before them that runs does
# not make them run again, and they make no step after them run again.
OWN_KEY_STEPS = ('prompts', 'scan')
# (a step that runs, a later step that reads nothing it writes): the later step is not made to run again. The lift
# reads only the unpacked ExeFS (step_key), so the RomFS step leaves it alone: an install that was cut short while the
# image was still being packed, the lift beside it already done, packs the image again but does not lift again.
UNAFFECTED = {('romfs', 'lift')}
# The Python packages tools/pad_prompts.py imports (pip name: import name), checked before a build with button art.
PROMPT_PACKAGES = {'zstandard': 'zstandard', 'fonttools': 'fontTools', 'pillow': 'PIL'}
# The line tools/pad_prompts.py prints for each overlay folder it wrote.
@@ -2060,10 +2064,10 @@ def main():
emit('step', step=name, state='skip')
else:
# a step that runs makes every step after it run too: their keys hash its output, not its key (but
# for OWN_KEY_STEPS, whose keys name their inputs)
# for OWN_KEY_STEPS, whose keys name their inputs, and a step that reads nothing of it, UNAFFECTED)
with state_lock:
for later in STEPS[STEPS.index(name):]:
if later == name or not {name, later} & set(OWN_KEY_STEPS):
if later == name or not ({name, later} & set(OWN_KEY_STEPS) or (name, later) in UNAFFECTED):
state['steps'].pop(later, None)
say(f'{name}:')
emit('step', step=name, state='start')