scripts: Move common arguments into build_helper.py

The two main QEMU scripts (build-efi and build-qemu) share some common
arguments, so put them in the common file.

Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
Simon Glass
2025-06-12 06:15:40 -06:00
parent c9832707e3
commit c44dd6832c
3 changed files with 34 additions and 43 deletions

View File

@@ -20,7 +20,7 @@ import os
from pathlib import Path
import shutil
from build_helper import Helper
import build_helper
# pylint: disable=C0413
from u_boot_pylib import command
@@ -36,40 +36,23 @@ def parse_args():
"""
parser = ArgumentParser(
epilog='Script for running U-Boot as an EFI app/payload')
build_helper.add_common_args(parser)
parser.add_argument('-a', '--app', action='store_true',
help='Package up the app')
parser.add_argument('-A', '--arm', action='store_true',
help='Run on ARM architecture')
parser.add_argument('-B', '--no-build', action='store_true',
help="Don't build (an existing build must be present")
parser.add_argument('-d', '--disk',
help='Root disk image file to use with QEMU')
parser.add_argument('-g', '--debug', action='store_true',
help="Run QEMU with gdb")
parser.add_argument(
'-k', '--kvm', action='store_true',
help='Use KVM (Kernel-based Virtual Machine) for acceleration')
parser.add_argument('-K', '--kernel', action='store_true',
help='Add a kernel')
parser.add_argument('-O', '--old', action='store_true',
help='Use old EFI app build (before 32/64 split)')
parser.add_argument('-o', '--os', metavar='NAME', choices=['ubuntu'],
help='Run a specified Operating System')
parser.add_argument('-p', '--payload', action='store_true',
help='Package up the payload')
parser.add_argument('-P', '--partition', action='store_true',
help='Create a partition table')
parser.add_argument('-r', '--run', action='store_true',
help='Run QEMU with the image')
parser.add_argument(
'-R', '--release', default='24.04.1',
help='Select OS release version (e.g, 24.04) Default: 24.04.1')
parser.add_argument('-s', '--serial', action='store_true',
help='Run QEMU with serial only (no display)')
parser.add_argument('-v', '--verbose', action='store_true',
help='Show executed commands')
parser.add_argument('-w', '--word', action='store_true',
help='Use word version (32-bit) rather than 64-bit')
args = parser.parse_args()
@@ -81,7 +64,7 @@ def parse_args():
class BuildEfi:
"""Class to collect together the various bits of state while running"""
def __init__(self, args):
self.helper = Helper()
self.helper = build_helper.Helper()
self.helper.read_settings()
self.img = self.helper.get_setting('efi_image_file', 'efi.img')
self.build_dir = self.helper.get_setting("build_dir", '/tmp')
@@ -204,7 +187,7 @@ class BuildEfi:
def start(self):
"""This does all the work"""
args = self.args
bitness = 32 if args.word else 64
bitness = 32 if args.word_32bit else 64
arch = 'arm' if args.arm else 'x86'
build_type = 'payload' if args.payload else 'app'
build = f'efi-{arch}_{build_type}{bitness}'
@@ -223,7 +206,7 @@ class BuildEfi:
command.run('cp', bzimage, f'{dirpath}/vmlinuz')
if args.run:
self.run_qemu(bitness, args.serial)
self.run_qemu(bitness, args.serial_only)
if __name__ == "__main__":