forked from cirosantilli/linux-kernel-module-cheat
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild-stream
More file actions
executable file
·63 lines (56 loc) · 2.03 KB
/
build-stream
File metadata and controls
executable file
·63 lines (56 loc) · 2.03 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/usr/bin/env python3
import os
import shutil
import common
import shlex
from shell_helpers import LF
class Main(common.BuildCliFunction):
def __init__(self):
super().__init__(
description='''\
https://cirosantilli.com/linux-kernel-module-cheat#stream-benchmark
'''
)
self._add_argument('--ccflags')
self._add_argument('--force-rebuild')
self._add_argument('--optimization-level')
def setup(self, env):
self.root_relpath = os.path.join('submodules', 'stream-benchmark')
def build(self):
build_dir = self.get_build_dir()
cflags = ['-O{}'.format(self.env['optimization_level'])]
extra_flags = []
if self.env['static']:
cflags.extend(['-static'])
if self.env['force_rebuild']:
extra_flags.extend(['-B', LF])
if self.env['mode'] == 'baremetal':
extra_objs = [
self.env['baremetal_syscalls_obj'],
self.env['baremetal_syscalls_asm_obj']
]
else:
extra_objs = []
ret = self.sh.run_cmd(
[
'make', LF,
'-j', str(self.env['nproc']), LF,
'-C', os.path.join(self.env['submodules_dir'], 'stream-benchmark'), LF,
'CC={}'.format(self.env['gcc_path']), LF,
'CFLAGS_EXTRA={}'.format(' '.join(cflags)), LF,
'EXTRA_OBJS={}'.format(' '.join(extra_objs)), LF,
'FC={}'.format(self.env['gfortran_path']), LF,
'OUT_DIR={}'.format(build_dir), LF,
]
+ extra_flags
)
if ret == 0 and self.env['copy_overlay']:
self.sh.copy_file_if_update(
os.path.join(build_dir, 'stream_c.exe'),
os.path.join(self.env['out_rootfs_overlay_lkmc_dir'], self.root_relpath, 'stream-benchmark'),
)
return ret
def get_build_dir(self):
return os.path.join(self.env['build_dir'], self.root_relpath)
if __name__ == '__main__':
Main().cli()