Key the lift step on the files in cheats, so extracting main does not rebuild the game

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
conongnangandClaude Opus 5.5 committed 2026-11-01 08:15:20 +07:00
1 parent d8cbdf1067
commit a81b00930e
2 files changed
+57 -1

No files matched your search

+8 -1
View File
@@ -533,6 +533,13 @@ EMITTED = re.compile(r'^emitted (\d+)/(\d+) chunks')
DISCOVERED = re.compile(r'^(\w+): \d+ functions \(.*discovery')
def cheat_files(ctx):
"""The Atmosphere cheat files in <dest>/cheats, for the lift key. All of them: the one the build reads goes by the
build id of the installed main, and the keys are computed before Extract runs (runner plan), when a fresh install
has no main and an update may still have another version's. The .status files beside them are lift's own output."""
return sorted((ctx.dest / 'cheats').glob('*.txt'))
def cheats_file(ctx):
"""<dest>/cheats/<build id>.txt, the Atmosphere cheat file of the installed main (tools/cheats.py), whether or not
it exists."""
@@ -550,7 +557,7 @@ class Lift(Step):
def key(self, ctx):
return fingerprint('lift-2', ctx.keys['extract'], ctx.layout.recomp, ctx.layout.patches(game_version(ctx)),
ctx.layout.tools / 'cheats.py', cheats_file(ctx))
ctx.layout.tools / 'cheats.py', *cheat_files(ctx))
def current(self, ctx, record):
gen = ctx.temp / 'gen'
+49
View File
@@ -197,6 +197,55 @@ class RunnerTest(unittest.TestCase):
self.assertEqual(e.exception.id, 'state.newer_format')
class ReleaseFilesTest(unittest.TestCase):
def test_release_ships_every_tool_the_steps_run(self):
sys.path.insert(0, str(ROOT / 'tools'))
import make_release
text = (ROOT / 'installer' / 'steps.py').read_text(encoding='utf-8')
used = set(re.findall(r"layout\.tools / '(\w+\.py)'", text))
for names in re.findall(r"layout\.tools / n for n in \((.*?)\)", text, re.S):
used |= set(re.findall(r"'(\w+\.py)'", names))
self.assertIn('cheats.py', used)
self.assertEqual(used - set(make_release.TOOLS_FILES), set())
class LiftKeyTest(unittest.TestCase):
def setUp(self):
tmp = tempfile.TemporaryDirectory()
self.addCleanup(tmp.cleanup)
self.dest = Path(tmp.name)
layout = SimpleNamespace(recomp=self.dest / 'no-recomp', tools=self.dest / 'no-tools',
patches=lambda version: self.dest / 'no-patches')
self.ctx = SimpleNamespace(dest=self.dest, layout=layout, keys={'extract': 'x'}, state={'version': '1.4.3'})
def key(self):
return steps.Lift().key(self.ctx)
def add_cheats(self, name, text):
(self.dest / 'cheats').mkdir(exist_ok=True)
(self.dest / 'cheats' / name).write_text(text)
def test_extracting_main_keeps_the_key(self):
before = self.key()
(self.dest / 'exefs').mkdir()
(self.dest / 'exefs' / 'main').write_bytes(bytes(0x48))
self.assertEqual(self.key(), before)
def test_cheat_files_change_the_key(self):
before = self.key()
self.add_cheats('277178B7DBA1B6D4.txt', '[a]')
added = self.key()
self.assertNotEqual(added, before)
self.add_cheats('277178B7DBA1B6D4.txt', '[b]')
self.assertNotEqual(self.key(), added)
def test_status_file_keeps_the_key(self):
self.add_cheats('277178B7DBA1B6D4.txt', '[a]')
before = self.key()
self.add_cheats('277178B7DBA1B6D4.status', 'written by lift')
self.assertEqual(self.key(), before)
class IniTest(unittest.TestCase):
EXAMPLE = '[display]\n# vk_present = mailbox\n\n[language]\n# locale = en-US\n# lang = en-US\n# x = 1\n'