Feat: build script UI/UX

This commit is contained in:
2026-03-17 12:54:57 +01:00
parent d72b36b8f1
commit ab93acd17f

View File

@@ -693,9 +693,22 @@ def run_builds(
for r in results:
_print_platform_log(r, verbose)
_write_build_log(root / OUT / "build.log", results)
return results
def _write_build_log(path: Path, results: list[PlatformResult]) -> None:
with open(path, "w") as f:
for r in results:
status = "OK" if r.success else "FAIL"
f.write(f"=== {r.platform.label} [{status}] {r.elapsed:.1f}s ===\n")
for line in r.log_lines:
f.write(line + "\n")
f.write("\n")
console.print(f" [dim]Build log written to {path}[/]")
_FAILURE_LOG_TAIL = 50
@@ -721,31 +734,6 @@ def _print_platform_log(r: PlatformResult, verbose: bool = False) -> None:
# ---------------------------------------------------------------------------
def _native_platforms(platforms: list[Platform]) -> list[Platform]:
return [p for p in platforms if p.native]
def _platforms_by_os(platforms: list[Platform], os_name: str) -> list[Platform]:
return [p for p in platforms if p.os == os_name]
def _build_presets(platforms: list[Platform]) -> list[tuple[str, list[Platform], BuildConfig]]:
"""Build a list of (label, platforms, config) presets."""
presets: list[tuple[str, list[Platform], BuildConfig]] = []
native = _native_platforms(platforms)
if native:
label = ", ".join(p.label for p in native)
presets.append((f"This machine ({label})", native, BuildConfig()))
macos = _platforms_by_os(platforms, "macos")
if len(macos) > 1:
presets.append(("macOS all (arm64 + x86_64)", macos, BuildConfig()))
presets.append(("Full release (all platforms, all targets)", list(platforms), BuildConfig()))
presets.append(("CLI only (all platforms, no desktop/plugins)", list(platforms), BuildConfig(desktop=False, plugins=False)))
return presets
def _ask_or_exit(prompt) -> any:
result = prompt.ask()
@@ -757,24 +745,6 @@ def _ask_or_exit(prompt) -> any:
def prompt_interactive(
all_platforms: list[Platform], alias_map: dict[str, Platform],
) -> tuple[list[Platform], BuildConfig]:
presets = _build_presets(all_platforms)
choices = [
*[questionary.Choice(label, value=i) for i, (label, _, _) in enumerate(presets)],
questionary.Separator(),
questionary.Choice("Custom...", value="custom"),
]
pick = _ask_or_exit(questionary.select(
"Build profile:", choices=choices, style=PROMPT_STYLE,
))
if pick != "custom":
_, platforms, config = presets[pick]
_print_summary(platforms, config)
return platforms, config
# Custom: platform checkboxes
plat_choices = [questionary.Choice(p.label, value=p.alias, checked=p.native) for p in all_platforms]
selected_aliases = _ask_or_exit(questionary.checkbox(
"Platforms:", choices=plat_choices, style=PROMPT_STYLE,
@@ -783,7 +753,6 @@ def prompt_interactive(
selected_aliases = [p.alias for p in all_platforms]
platforms = [alias_map[a] for a in selected_aliases]
# Custom: target checkboxes
target_choices = [
questionary.Choice("CLI", value="cli", checked=True),
questionary.Choice("Desktop", value="desktop", checked=True),