-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathquados
executable file
·99 lines (84 loc) · 2.07 KB
/
quados
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
99
#!/bin/env python3
import argparse
import subprocess
from scripts import config, cargo, qemu
def parse_args():
parser = argparse.ArgumentParser(description="Build Quados.")
parser.add_argument(
"-arch",
"--architecture",
dest="arch",
choices=config.target_list.keys(),
default="riscv64",
type=str,
help="Specify the architecture",
)
parser.add_argument(
"-p",
"--platform",
dest="platform",
type=str,
default="riscv64-qemu",
help="Specify the binary configuration",
)
parser.add_argument(
"-f",
"--rootfs",
dest="rootfs",
type=str,
default="ext4",
help="Specify the root filesystem",
)
parser.add_argument(
"-l",
"--log",
dest="log",
choices=["off", "trace", "debug", "info", "warn", "error"],
type=str,
default="error",
help="Set the kernel logging level"
)
parser.add_argument(
"-g",
"--graphic",
dest="graphic",
action="store_true",
default=False,
help="Add graphic information"
)
parser.add_argument(
"method",
# dest="method",
choices=method_map.keys(),
help="Specify the operation to be performed"
)
parser.add_argument(
"-d",
"--debug",
dest="debug",
action="store_true",
default=False,
help="Use gdb to debug the kernel"
)
args = parser.parse_args()
config.arch = args.arch
config.platform = args.platform
config.rootfs = args.rootfs
config.log = args.log
config.graphic = args.graphic
config.gdb = args.debug
return args
def run_qemu():
method_map["build"]()
qemu.run()
def clean():
subprocess.run(["rm", "-rf", "target", "qemu.log", "mount.img"])
method_map = {
"build": cargo.build,
"qemu": run_qemu,
"clean": clean
}
if __name__ == "__main__":
args = parse_args()
config.build()
method_map[args.method]()