11from __future__ import annotations
22
3+ import shutil
34from pathlib import Path
45from typing import Annotated
56
@@ -25,6 +26,7 @@ def application_command(
2526 version : Annotated [str , typer .Option (..., "--version" )],
2627 engine_archive : Annotated [Path , typer .Option (..., "--engine-archive" , exists = True , dir_okay = False )],
2728 run_config : Annotated [Path , typer .Option ("--run-config" )] = Path ("config/ui-rust.json" ),
29+ editor_archive_output : Annotated [Path | None , typer .Option ("--editor-archive-output" )] = None ,
2830 archive : Annotated [bool , typer .Option ("--archive/--no-archive" )] = True ,
2931) -> None :
3032 build_application (
@@ -36,6 +38,7 @@ def application_command(
3638 platform = platform ,
3739 version = version ,
3840 run_config = run_config ,
41+ editor_archive_output = editor_archive_output ,
3942 archive = archive ,
4043 )
4144
@@ -50,6 +53,7 @@ def build_application(
5053 platform : str ,
5154 version : str ,
5255 run_config : Path ,
56+ editor_archive_output : Path | None ,
5357 archive : bool ,
5458) -> Path :
5559 normalized_platform = normalize_platform (platform )
@@ -63,7 +67,7 @@ def build_application(
6367
6468 resolved_repo_root = repo_root .resolve ()
6569 game_name = resolve_game_name (resolved_repo_root , version )
66- prepare_game_archive (
70+ game_archive = prepare_game_archive (
6771 repo_root = resolved_repo_root ,
6872 files_dir = resolved_output ,
6973 game_name = game_name ,
@@ -74,6 +78,8 @@ def build_application(
7478 run_config = run_config ,
7579 loading_image = find_engine_loading_image (resolved_output ),
7680 )
81+ if editor_archive_output is not None :
82+ export_editor_archive (game_archive , editor_archive_output )
7783
7884 config = read_application_config (distribution .resolve ())
7985 (resolved_output / "script.txt" ).write_text (render_start_script (game_name , config .launch ), encoding = "utf-8" )
@@ -88,5 +94,18 @@ def build_application(
8894 return resolved_output
8995
9096
97+ def export_editor_archive (game_archive : Path , output : Path ) -> Path :
98+ resolved_output = output .resolve ()
99+ if resolved_output .suffix .lower () != ".sdz" :
100+ raise RuntimeError (f"Editor archive output must end in .sdz: { resolved_output } " )
101+ if resolved_output .exists ():
102+ raise RuntimeError (f"Refusing to overwrite editor archive: { resolved_output } " )
103+ resolved_output .parent .mkdir (parents = True , exist_ok = True )
104+ shutil .copy2 (game_archive , resolved_output )
105+ write_sha256 (resolved_output )
106+ print (f"Created editor archive: { resolved_output } " )
107+ return resolved_output
108+
109+
91110def main () -> None :
92111 app ()
0 commit comments