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:
Ciro Santilli 六四事件 法轮功
2018-10-18 00:00:00 +00:00
parent cb3d8929ba
commit 2a77df690c
10 changed files with 650 additions and 595 deletions

View File

@@ -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()