diff options
| author | 魏曹先生 <1992414357@qq.com> | 2026-06-18 04:44:08 +0800 |
|---|---|---|
| committer | 魏曹先生 <1992414357@qq.com> | 2026-06-18 04:44:08 +0800 |
| commit | 133ab48d0d9ac1d0f8ad87b7a71b8e6cd4f7d402 (patch) | |
| tree | 8f6b56b0db2c0869754a8b7be92f7c4802a2b3f4 | |
| parent | f2ba5aa4cc0907dbe7f627b6843088794b807cc6 (diff) | |
feat(scripts): copy executables to .temp/bin after build
Add post-build step to copy release executables to a dedicated bin
directory
| -rw-r--r-- | rola-devtools/scripts/build.py | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/rola-devtools/scripts/build.py b/rola-devtools/scripts/build.py index cd2ddf1..c63ca23 100644 --- a/rola-devtools/scripts/build.py +++ b/rola-devtools/scripts/build.py @@ -1,5 +1,6 @@ #!/usr/bin/env python3 +import shutil import subprocess import sys from pathlib import Path @@ -7,6 +8,14 @@ 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", @@ -35,4 +44,31 @@ for label, cmd in steps: 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) |
