scripts: Support --bootcmd more generally

Add -b as a short alias for --bootcmd to build_helper so it is available
in both build-qemu and build-efi

Move the fw_cfg bootcmd logic to build_helper as well.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
Simon Glass
2025-10-25 08:30:13 +01:00
parent ce00a8112c
commit 2c415606fd
2 changed files with 7 additions and 7 deletions

View File

@@ -41,8 +41,6 @@ def parse_args():
description='Build and/or run U-Boot with QEMU',
formatter_class=argparse.RawTextHelpFormatter)
build_helper.add_common_args(parser)
parser.add_argument('--bootcmd', type=str,
help='U-Boot bootcmd to pass via fw_cfg')
parser.add_argument('-e', '--sct-run', action='store_true',
help='Run UEFI Self-Certification Test (SCT)')
parser.add_argument('-E', '--use-tianocore', action='store_true',
@@ -297,11 +295,6 @@ class BuildQemu:
# Add other parameters gathered from options
qemu_cmd.extend(self.qemu_extra)
# Add bootcmd via fw_cfg if specified
if self.args.bootcmd:
qemu_cmd.extend(['-fw_cfg',
f'name=opt/u-boot/bootcmd,string={self.args.bootcmd}'])
self.helper.setup_share(qemu_cmd)
self.helper.run(qemu_cmd)

View File

@@ -189,6 +189,11 @@ sct_mnt = /mnt/sct
cmd.extend(['-object', 'rng-random,filename=/dev/urandom,id=rng0',
'-device', 'virtio-rng-pci,rng=rng0'])
# Add bootcmd via fw_cfg if specified
if args.bootcmd:
cmd.extend(['-fw_cfg',
f'name=opt/u-boot/bootcmd,string={args.bootcmd}'])
def setup_share(self, qemu_cmd):
sock = Path('/tmp/virtiofs.sock')
proc = None
@@ -285,6 +290,8 @@ def add_common_args(parser):
"""
parser.add_argument('-a', '--arch', default='arm', choices=['arm', 'x86'],
help='Select architecture (arm, x86) Default: arm')
parser.add_argument('-b', '--bootcmd', type=str,
help='U-Boot bootcmd to pass via fw_cfg')
parser.add_argument('-B', '--no-build', action='store_true',
help="Don't build; assume a build exists")
parser.add_argument('--build-dir', help='Directory to use for the build')