mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-22 17:55:57 +01:00
configure args are now ./build-qemu --extra-config-args '"aa a" bb' Also factor out arg names with other builds through _add_argument. Fix #113.
63 lines
1.9 KiB
Python
Executable File
63 lines
1.9 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
|
|
import os
|
|
|
|
import common
|
|
from shell_helpers import LF
|
|
|
|
class Main(common.BuildCliFunction):
|
|
def __init__(self):
|
|
super().__init__()
|
|
self._add_argument('--configure')
|
|
self.add_argument('--extra-config-args')
|
|
self._add_argument('extra_make_args')
|
|
|
|
def build(self):
|
|
build_dir = self.get_build_dir()
|
|
os.makedirs(build_dir, exist_ok=True)
|
|
if self.env['verbose']:
|
|
verbose = ['V=1']
|
|
else:
|
|
verbose = []
|
|
if self.env['mode'] == 'userland':
|
|
target_list = '{}-linux-user'.format(self.env['arch'])
|
|
else:
|
|
target_list = '{}-softmmu'.format(self.env['arch'])
|
|
if self.env['qemu_build_type'] == 'debug':
|
|
# https://stackoverflow.com/questions/4689136/debug-qemu-with-gdb
|
|
build_type_cmd = ['--enable-debug', LF]
|
|
else:
|
|
build_type_cmd = []
|
|
if self.env['configure']:
|
|
self.sh.run_cmd(
|
|
[
|
|
os.path.join(self.env['qemu_source_dir'], 'configure'), LF,
|
|
'--enable-trace-backends=simple', LF,
|
|
'--target-list={}'.format(target_list), LF,
|
|
'--enable-sdl', LF,
|
|
] +
|
|
build_type_cmd +
|
|
self.sh.shlex_split(self.env['extra_config_args']),
|
|
extra_paths=[self.env['ccache_dir']],
|
|
cwd=build_dir
|
|
)
|
|
self.sh.run_cmd(
|
|
(
|
|
[
|
|
'make', LF,
|
|
'-j', str(self.env['nproc']), LF,
|
|
|
|
] +
|
|
verbose +
|
|
self.sh.add_newlines(self.env['extra_make_args'])
|
|
),
|
|
cwd=build_dir,
|
|
extra_paths=[self.env['ccache_dir']],
|
|
)
|
|
|
|
def get_build_dir(self):
|
|
return self.env['qemu_build_dir']
|
|
|
|
if __name__ == '__main__':
|
|
Main().cli()
|