forked from atsamd-rs/atsamd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-all.py
executable file
·40 lines (29 loc) · 1.17 KB
/
build-all.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
32
33
34
35
36
37
38
39
40
#!/usr/bin/env python3
import json
import shlex
import subprocess
from pathlib import PurePath
def main(clean=False, build=False):
with open("crates.json", "r") as f:
crates = json.load(f)
for (board, jobs) in crates["boards"].items():
print()
print("-" * 80)
print(f"Crate: {board}")
print(f"Command: {jobs['build']}\n")
command = shlex.split(jobs["build"])
crate_path = PurePath("boards", board)
if clean:
subprocess.check_call(shlex.split("cargo clean"), cwd=crate_path)
subprocess.check_call(shlex.split("cargo update"), cwd=crate_path)
if build:
subprocess.check_call(command, cwd=crate_path)
else:
subprocess.check_call(shlex.split("cargo outdated"), cwd=crate_path)
if __name__ == "__main__":
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--clean", action="store_true", help="run `cargo clean` and `cargo update` before building")
parser.add_argument("--no-build", action="store_true", help="Don't build the crates")
args = parser.parse_args()
main(clean=args.clean, build=not args.no_build)