mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-26 03:31:36 +01:00
build-qemu
This commit is contained in:
10
build
10
build
@@ -134,7 +134,6 @@ def main(args, extra_args=None):
|
||||
kernel_config_fragments.append(os.path.join(kernel_config_fragment_cli_path))
|
||||
if True:
|
||||
# Kernel configuration fragments.
|
||||
kernel_config_fragment_dir = os.path.join('..', 'kernel_config_fragment')
|
||||
if args.kernel_custom_config_file is not None:
|
||||
if os.path.exists(args.kernel_custom_config_file):
|
||||
buildroot_configs.extend([
|
||||
@@ -147,13 +146,16 @@ def main(args, extra_args=None):
|
||||
raise Exception('Kernel config fragment file does not exist: {}'.format(args.kernel_custom_config_file))
|
||||
default_kernel_config_fragments = []
|
||||
else:
|
||||
default_kernel_config_fragments = ['min', 'default', 'display']
|
||||
kernel_config_fragment_dir = os.path.join(common.root_dir, 'kernel_config_fragments')
|
||||
default_kernel_config_fragments = ['min']
|
||||
if args.linux_reconfigure:
|
||||
# https://stackoverflow.com/questions/49260466/why-when-i-change-br2-linux-kernel-custom-config-file-and-run-make-linux-reconfi
|
||||
pathlib.Path(os.path.join(kernel_config_fragment_dir, 'min')).touch()
|
||||
for i, default_kernel_config_fragment in enumerate(default_kernel_config_fragments):
|
||||
default_kernel_config_fragments[i] = os.path.join(kernel_config_fragment_dir, default_kernel_config_fragment)
|
||||
kernel_config_fragments.extend(default_kernel_config_fragments)
|
||||
for i, frag in enumerate(kernel_config_fragments):
|
||||
kernel_config_fragments[i] = path_relative_to_buildroot(frag)
|
||||
buildroot_kernel_config_fragment_str = 'BR2_LINUX_KERNEL_CONFIG_FRAGMENT_FILES="{}"'.format(' '.join(kernel_config_fragments))
|
||||
buildroot_configs.append(buildroot_kernel_config_fragment_str)
|
||||
|
||||
@@ -193,10 +195,6 @@ def main(args, extra_args=None):
|
||||
# ln -s "$variant_dir" "$custom_dir"
|
||||
#)
|
||||
#symlink_buildroot_variant "$common_linux_build_dir" "$common_linux_variant_dir"
|
||||
#symlink_buildroot_variant "$common_qemu_build_dir" "$common_qemu_variant_dir"
|
||||
## TODO: this breaks the build. But then I noticed that it wouldn't make sense,
|
||||
## because this is a guest tool, and we don't have image variants yet. Some other day maybe.
|
||||
##symlink_buildroot_variant "$common_qemu_guest_build_dir" "$common_qemu_guest_variant_dir"
|
||||
|
||||
## Manage gem5 variants.
|
||||
#if "$common_gem5"; then
|
||||
|
||||
41
build-qemu
Executable file
41
build-qemu
Executable file
@@ -0,0 +1,41 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import multiprocessing
|
||||
import os
|
||||
import subprocess
|
||||
|
||||
import common
|
||||
|
||||
parser = common.get_argparse(argparse_args={
|
||||
'description': 'Build QEMU'
|
||||
})
|
||||
parser.add_argument(
|
||||
'extra_config_args',
|
||||
default=[],
|
||||
help='Extra arguments for the tool.',
|
||||
metavar='extra-config-args',
|
||||
nargs='*'
|
||||
)
|
||||
args = common.setup(parser)
|
||||
os.makedirs(common.qemu_build_dir, exist_ok=True)
|
||||
subprocess.check_call(
|
||||
[
|
||||
os.path.join(common.qemu_src_dir, 'configure'),
|
||||
'--enable-debug',
|
||||
'--enable-trace-backends=simple',
|
||||
'--target-list={}-softmmu'.format(args.arch),
|
||||
'--enable-sdl',
|
||||
'--with-sdlabi=2.0',
|
||||
] +
|
||||
args.extra_config_args,
|
||||
cwd=common.qemu_build_dir
|
||||
)
|
||||
subprocess.check_call(
|
||||
[
|
||||
'make',
|
||||
'-j',
|
||||
# TODO factor with build.
|
||||
str(multiprocessing.cpu_count()),
|
||||
],
|
||||
cwd=common.qemu_build_dir
|
||||
)
|
||||
@@ -297,10 +297,8 @@ def setup(parser, **extra_args):
|
||||
this.linux_build_dir = os.path.join(this.build_dir, 'linux-custom')
|
||||
this.linux_variant_dir = '{}.{}'.format(this.linux_build_dir, args.linux_build_id)
|
||||
this.vmlinux = os.path.join(this.linux_variant_dir, "vmlinux")
|
||||
this.qemu_build_dir = os.path.join(this.build_dir, 'host-qemu-custom')
|
||||
this.qemu_guest_variant_dir = os.path.join(this.qemu_build_dir, args.qemu_build_id)
|
||||
this.qemu_variant_dir = '{}.{}'.format(this.qemu_build_dir, args.qemu_build_id)
|
||||
this.qemu_executable = os.path.join(this.qemu_variant_dir, '{}-softmmu'.format(args.arch), 'qemu-system-{}'.format(args.arch))
|
||||
this.qemu_build_dir = os.path.join(this.common_dir, 'qemu', args.qemu_build_id)
|
||||
this.qemu_executable = os.path.join(this.qemu_build_dir, '{}-softmmu'.format(args.arch), 'qemu-system-{}'.format(args.arch))
|
||||
this.qemu_guest_build_dir = os.path.join(this.build_dir, 'qemu-custom')
|
||||
this.host_dir = os.path.join(this.buildroot_out_dir, 'host')
|
||||
this.host_bin_dir = os.path.join(this.host_dir, 'usr', 'bin')
|
||||
|
||||
Reference in New Issue
Block a user