mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-23 10:15:57 +01:00
46 lines
1.4 KiB
Python
Executable File
46 lines
1.4 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
|
|
import multiprocessing
|
|
import os
|
|
import platform
|
|
import subprocess
|
|
import time
|
|
|
|
import common
|
|
|
|
class M5Component(common.Component):
|
|
def get_make_cmd(self, args):
|
|
allowed_toolchains = ['buildroot']
|
|
cc = common.get_toolchain_tool('gcc', allowed_toolchains=allowed_toolchains)
|
|
ld = common.get_toolchain_tool('ld', allowed_toolchains=allowed_toolchains)
|
|
if args.arch == 'x86_64':
|
|
arch = 'x86'
|
|
else:
|
|
arch = args.arch
|
|
return [
|
|
'make',
|
|
'-j', str(multiprocessing.cpu_count()),
|
|
'-f', 'Makefile.{}'.format(arch),
|
|
'CC={}'.format(cc),
|
|
'LD={}'.format(ld),
|
|
'PWD={}'.format(common.gem5_m5_src_dir),
|
|
]
|
|
|
|
def do_build(self, args):
|
|
os.makedirs(common.gem5_m5_build_dir, exist_ok=True)
|
|
assert common.run_cmd(
|
|
self.get_make_cmd(args),
|
|
cwd=common.gem5_m5_src_dir,
|
|
) == 0
|
|
print(common.out_rootfs_overlay_bin_dir)
|
|
os.makedirs(common.out_rootfs_overlay_bin_dir, exist_ok=True)
|
|
common.cp(os.path.join(common.gem5_m5_src_dir, 'm5'), common.out_rootfs_overlay_bin_dir)
|
|
|
|
def clean(self, args):
|
|
assert common.run_cmd(
|
|
self.get_make_cmd(args) + ['clean'],
|
|
cwd=common.gem5_m5_src_dir,
|
|
) == 0
|
|
|
|
M5Component().build()
|