forked from cirosantilli/linux-kernel-module-cheat
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild-m5
More file actions
executable file
·48 lines (41 loc) · 1.39 KB
/
build-m5
File metadata and controls
executable file
·48 lines (41 loc) · 1.39 KB
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
#!/usr/bin/env python3
import os
import common
from shell_helpers import LF
class Main(common.BuildCliFunction):
def __init__(self):
super().__init__(
description='''\
Build the gem5 m5 executable.
See: https://cirosantilli.com/linux-kernel-module-cheat#gem5-m5-executable
'''
)
def _get_make_cmd(self):
allowed_toolchains = ['buildroot']
return [
'scons', LF,
'-C', self.env['gem5_m5_source_dir'], LF,
'-j', str(self.env['nproc']), LF,
'CROSS_COMPILE={}'.format(self.env['toolchain_prefix_dash']), LF,
self.env['gem5_m5_source_dir_build'], LF
]
def build(self):
os.makedirs(self.env['gem5_m5_build_dir'], exist_ok=True)
# We must clean first or else the build outputs of one arch can conflict with the other.
# I should stop being lazy and go actually patch gem5 to support out of tree m5 build...
self.clean()
self.sh.run_cmd(
self._get_make_cmd(),
)
os.makedirs(self.env['out_rootfs_overlay_bin_dir'], exist_ok=True)
self.sh.cp(
self.env['gem5_m5_source_dir_build'],
self.env['out_rootfs_overlay_bin_dir']
)
def clean(self):
self.sh.run_cmd(
self._get_make_cmd() + ['--clean', LF],
)
return None
if __name__ == '__main__':
Main().cli()