mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-23 10:15:57 +01:00
Only one --host exists at ./build-modules, since that can select the host kernel, which is independent from the toolchain. Document that user mode simulation stopped working.
47 lines
1.5 KiB
Python
Executable File
47 lines
1.5 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
|
|
import os
|
|
|
|
import common
|
|
from shell_helpers import LF
|
|
|
|
class Main(common.BuildCliFunction):
|
|
def _get_make_cmd(self):
|
|
allowed_toolchains = ['buildroot']
|
|
cc = self.get_toolchain_tool('gcc')
|
|
ld = self.get_toolchain_tool('ld')
|
|
if self.env['arch'] == 'x86_64':
|
|
arch = 'x86'
|
|
else:
|
|
arch = self.env['arch']
|
|
return [
|
|
'make', LF,
|
|
'-j', str(self.env['nproc']), LF,
|
|
'-f', 'Makefile.{}'.format(arch), LF,
|
|
'CC={}'.format(cc), LF,
|
|
'LD={}'.format(ld), LF,
|
|
'PWD={}'.format(self.env['gem5_m5_source_dir']), 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(),
|
|
cwd=self.env['gem5_m5_source_dir'],
|
|
)
|
|
os.makedirs(self.env['out_rootfs_overlay_bin_dir'], exist_ok=True)
|
|
self.sh.cp(os.path.join(self.env['gem5_m5_source_dir'], 'm5'), self.env['out_rootfs_overlay_bin_dir'])
|
|
|
|
def clean(self):
|
|
self.sh.run_cmd(
|
|
self._get_make_cmd() + ['clean', LF],
|
|
cwd=self.env['gem5_m5_source_dir'],
|
|
)
|
|
return None
|
|
|
|
if __name__ == '__main__':
|
|
Main().cli()
|