-
Notifications
You must be signed in to change notification settings - Fork 51
/
install.py
executable file
·98 lines (84 loc) · 2.21 KB
/
install.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#!/usr/bin/env python
#
# Copyright (C) 2016-2020, AdaCore
#
# Python script to build and install the Embedded runtimes for Bare-Metal
# targets.
import getopt
import os
import subprocess
import sys
def usage():
"""Script usage"""
print("usage: install.py [--arch=arm-eabi|aarch64-elf] [--prefix=<path>]")
print(" --arch: only build for the specified architecture")
print(" --prefix: installation prefix for the runtimes")
print("")
print("By default:")
print(" Builds and installs all targets for which a compiler is")
print(" available. The runtimes are installed in the toolchain itself.")
ALL_BSP = {
"arm-eabi": [
"stm32f4",
"nucleo_f401re",
"stm32f429disco",
"stm32f469disco",
"stm32f746disco",
"stm32756geval",
"stm32f769disco",
"samg55",
"sam4s",
"samrh71",
"samv71",
"openmv2",
"rpi2",
"feather_stm32f405",
"stm32f051r8-hsi",
"nrf52832",
"nrf52833",
"nrf52840",
"cortex-m0",
"cortex-m0p",
"cortex-m1",
"cortex-m3",
"cortex-m4",
"cortex-m4f",
"cortex-m7f",
"cortex-m7df",
"cortex-m23",
"cortex-m33f",
"cortex-m33df",
"rpi-pico",
"rpi-pico-smp",
],
"aarch64-elf": ["rpi3"],
}
def main():
try:
opts, args = getopt.getopt(sys.argv[1:], "", ["arch=", "prefix=", "help"])
except getopt.GetoptError as e:
print("error: " + str(e))
usage()
sys.exit(2)
prefix = None
arch = None
for opt, arg in opts:
if opt == "--help":
usage()
sys.exit()
elif opt == "--arch":
arch = arg
elif opt == "--prefix":
prefix = os.path.abspath(arg)
assert arch is None or arch in ALL_BSP, "unsupported arch %s" % arch
cmd = [sys.executable, "./build_rts.py", "--build", "--force"]
if prefix is not None:
cmd.append("--output=%s" % prefix)
if arch is None:
for k, v in ALL_BSP.items():
cmd += v
else:
cmd += ALL_BSP[arch]
subprocess.check_call(cmd)
if __name__ == "__main__":
main()