mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-25 11:11:35 +01:00
common: create a Component class to factor out builds
Not yet finished factoring, but half way there, do for all build-
This commit is contained in:
54
build-m5
54
build-m5
@@ -3,29 +3,21 @@
|
||||
import multiprocessing
|
||||
import os
|
||||
import platform
|
||||
import shutil
|
||||
import subprocess
|
||||
import time
|
||||
|
||||
import common
|
||||
|
||||
parser = common.get_argparse(argparse_args={
|
||||
'description': 'Build the m5 executable',
|
||||
})
|
||||
common.add_build_arguments(parser)
|
||||
args = common.setup(parser)
|
||||
start_time = time.time()
|
||||
os.makedirs(common.gem5_m5_build_dir, exist_ok=True)
|
||||
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
|
||||
assert common.run_cmd(
|
||||
(
|
||||
[
|
||||
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),
|
||||
@@ -33,11 +25,21 @@ assert common.run_cmd(
|
||||
'LD={}'.format(ld),
|
||||
'PWD={}'.format(common.gem5_m5_src_dir),
|
||||
]
|
||||
),
|
||||
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)
|
||||
shutil.copy2(os.path.join(common.gem5_m5_src_dir, 'm5'), common.out_rootfs_overlay_bin_dir)
|
||||
end_time = time.time()
|
||||
common.print_time(end_time - start_time)
|
||||
|
||||
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()
|
||||
|
||||
Reference in New Issue
Block a user