Files
linux-kernel-module-cheat/build-m5
Ciro Santilli 六四事件 法轮功 8fb9db3931 manually encode newlines on all printed commands
This way we group key value arguments: e.g.:

    make \
    -j 8 \
    all

instead of:

    make \
    -j \
    8 \
    all

and reach CLI nirvana, while also subtly breaking several commands due to
lack of testing.
2018-11-04 00:00:01 +00:00

45 lines
1.5 KiB
Python
Executable File

#!/usr/bin/env python3
import os
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', common.Newline,
'-j', str(args.nproc), common.Newline,
'-f', 'Makefile.{}'.format(arch), common.Newline,
'CC={}'.format(cc), common.Newline,
'LD={}'.format(ld), common.Newline,
'PWD={}'.format(common.gem5_m5_src_dir), common.Newline,
]
def do_build(self, args):
os.makedirs(common.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(args)
common.run_cmd(
self.get_make_cmd(args),
cwd=common.gem5_m5_src_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):
common.run_cmd(
self.get_make_cmd(args) + ['clean', common.Newline],
cwd=common.gem5_m5_src_dir,
)
if __name__ == '__main__':
M5Component().build()