#!/usr/bin/env python3 import shutil import subprocess import sys from pathlib import Path script_dir = Path(__file__).resolve().parent root_dir = script_dir.parent.parent def get_exe_names(): """Return the list of executable file names to copy (with or without .exe suffix).""" return [ "rola", ] steps = [ ("cargo check --workspace", [ "cargo", "check", "--workspace", ]), ("cargo clippy --workspace -- -D warnings", [ "cargo", "clippy", "--workspace", "--", "-D", "warnings", ]), ("cargo build --workspace --release", [ "cargo", "build", "--workspace", "--release", ]), ("dotnet restore", [ "dotnet", "restore", "rola-desktop.sln", ]), ("dotnet build", [ "dotnet", "build", "rola-desktop.sln", "--nologo", ]), ] ok = True for label, cmd in steps: print(f"\nSTEP - \"{label}\": ", flush=True) result = subprocess.run(cmd, cwd=root_dir) if result.returncode != 0: print(f" [FAILED] Failed (exit code {result.returncode})", flush=True) ok = False break print(f" [SUCCESS] Passed", flush=True) if ok: print(f"\nSTEP - \"Copy executables to .temp/bin\": ", flush=True) src_dir = root_dir / ".temp" / "target" / "release" dst_dir = root_dir / ".temp" / "bin" dst_dir.mkdir(parents=True, exist_ok=True) all_ok = True for exe_name in get_exe_names(): candidates = [] for suffix in ("", ".exe"): p = src_dir / f"{exe_name}{suffix}" if p.is_file(): candidates.append(p) if not candidates: print(f" [FAILED] Executable '{exe_name}' not found in {src_dir}", flush=True) all_ok = False continue for p in candidates: dst_path = dst_dir / p.name try: shutil.copy2(p, dst_path) print(f" [SUCCESS] Copied {p.name} -> {dst_path}", flush=True) except Exception as e: print(f" [FAILED] Failed to copy {p.name}: {e}", flush=True) all_ok = False if not all_ok: ok = False sys.exit(0 if ok else 1)