Debian Codegraph @

debian/rust-vendor/blake3/.github/workflows/build_b3sum.py

raw
1 #! /usr/bin/env python3
2
3 from pathlib import Path
4 import platform
5 import shutil
6 import subprocess
7 import sys
8
9 ROOT = Path(__file__).parent.parent.parent
10 RUST_TARGET = sys.argv[1]
11
12 subprocess.run(
13 ["cargo", "build", "--target", sys.argv[1], "--release"], cwd=ROOT / "b3sum"
14 )
15
16 if platform.system() == "Windows":
17 original_exe_name = "b3sum.exe"
18 else:
19 original_exe_name = "b3sum"
20
21 if platform.system() == "Windows":
22 new_exe_name = "b3sum_windows_x64_bin.exe"
23 elif platform.system() == "Darwin":
24 new_exe_name = "b3sum_macos_x64_bin"
25 elif platform.system() == "Linux":
26 new_exe_name = "b3sum_linux_x64_bin"
27 else:
28 raise RuntimeError("Unexpected platform: " + platform.system())
29
30 # Copy the built binary so that it has the upload name we want.
31 out_dir = ROOT / "b3sum/target" / RUST_TARGET / "release"
32 original_exe_path = str(out_dir / original_exe_name)
33 new_exe_path = str(out_dir / new_exe_name)
34 print("copying", repr(original_exe_path), "to", repr(new_exe_path))
35 shutil.copyfile(original_exe_path, new_exe_path)
36
37 # This lets the subsequent upload step get the filepath.
38 print("::set-output name=bin_path::" + new_exe_path)