-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.py
executable file
·31 lines (28 loc) · 945 Bytes
/
build.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/env python3
import json
import os
from subprocess import Popen, PIPE, run
import sys
# Build.
args = [
"cargo", "+nightly", "build",
"--target", "x86_64-unknown-none",
"-r",
"-Z", "build-std=alloc,core,panic_abort",
"-Z", "build-std-features=panic_immediate_abort",
"--message-format", "json-render-diagnostics"
]
with Popen(args, cwd="dumper", env=dict(os.environ, RUSTFLAGS="--cfg fw=\"1100\""), stdout=PIPE) as proc:
for line in proc.stdout:
line = json.loads(line)
reason = line["reason"]
if reason == "build-finished":
if line["success"]:
break
else:
sys.exit(1)
elif reason == "compiler-artifact":
if line["target"]["name"] == "dumper":
out = line["executable"]
# Create payload.
run(["rustup", "run", "nightly", "objcopy", "-O", "binary", out, "firmware-dumper.bin"], check=True)