diff --git a/launcher/build.py b/launcher/build.py index 63eb4374..40fa2341 100644 --- a/launcher/build.py +++ b/launcher/build.py @@ -36,8 +36,10 @@ def install_args(layout, dump, game_dir): return [*src, '--out', str(game_dir), '--msys', str(layout.msys)] -def rebuild_args(layout, game_dir): - return ['--rebuild', '--out', str(game_dir), '--msys', str(layout.msys)] +def rebuild_args(layout, game_dir, retune=False): + """retune: Rebuild the Game, which compiles the game's code for this processor's level; an update keeps the level + its objects were compiled for, so that it compiles only what changed (tools/make_game.py lifted_level).""" + return ['--rebuild', *(['--retune'] if retune else []), '--out', str(game_dir), '--msys', str(layout.msys)] def check_args(dump): diff --git a/launcher/jobs.py b/launcher/jobs.py index 00d275f1..8a832331 100644 --- a/launcher/jobs.py +++ b/launcher/jobs.py @@ -316,6 +316,7 @@ class InstallJob(Job): class RebuildJob(Job): kind = 'rebuild' title = 'Rebuilding' + retune = True # Rebuild the Game: the game's code for this processor's level (build.rebuild_args) def __init__(self, ctx, game_dir, dump=''): super().__init__(ctx, ['tools_update', 'lift', 'compile_changed', 'swap', 'shaders', *prompt_rows(ctx)]) @@ -327,7 +328,7 @@ class RebuildJob(Job): if build.game_running(self.game_dir): raise build.BuildError('the game is running: close it and try again') if build.can_rebuild(self.game_dir): - args = build.rebuild_args(layout, self.game_dir) + args = build.rebuild_args(layout, self.game_dir, self.retune) elif self.dump: args = build.install_args(layout, self.dump, self.game_dir) else: @@ -372,6 +373,7 @@ class UpdateDownloadJob(Job): class ContinueUpdateJob(RebuildJob): """After the restart, in the new version: bring the tools to its lock and rebuild the game.""" + retune = False # an update keeps the compiled game's level, so it compiles only what changed kind = 'update' def __init__(self, ctx, game_dir, old, dump=''): diff --git a/tests/launcher_test.py b/tests/launcher_test.py index ab729d10..305937c2 100644 --- a/tests/launcher_test.py +++ b/tests/launcher_test.py @@ -301,6 +301,17 @@ class GameIniTest(Tmp): self.assertTrue((self.tmp / 'nx2navi.ini').is_dir()) +class RebuildArgsTest(Tmp): + """Rebuild the Game compiles the game's code for this processor's level (--retune); an update keeps the level its + objects were compiled for, so that it compiles only what changed (tools/make_game.py lifted_level).""" + + def test_retune_only_for_rebuild_the_game(self): + self.assertIn('--retune', build.rebuild_args(self.layout, 'G:/game', True)) + self.assertNotIn('--retune', build.rebuild_args(self.layout, 'G:/game')) + self.assertTrue(jobs.RebuildJob.retune) + self.assertFalse(jobs.ContinueUpdateJob.retune) + + class SettingsTest(Tmp): def test_roundtrip_and_reset(self): s = settings.Settings(self.layout.settings)