[Concept,4/7] scripts: Support --bootcmd more generally

Message ID 20251029061657.1456910-5-sjg@u-boot.org
State New
Headers
Series efi: Minor improvements to QEMU and build scripts |

Commit Message

Simon Glass Oct. 29, 2025, 6:16 a.m. UTC
  From: Simon Glass <sjg@chromium.org>

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>
---

 scripts/build-qemu      | 7 -------
 scripts/build_helper.py | 7 +++++++
 2 files changed, 7 insertions(+), 7 deletions(-)
  

Patch

diff --git a/scripts/build-qemu b/scripts/build-qemu
index 70dfe968f66..3d59012ed5e 100755
--- a/scripts/build-qemu
+++ b/scripts/build-qemu
@@ -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)
diff --git a/scripts/build_helper.py b/scripts/build_helper.py
index d401da0215c..8bce9a6183c 100644
--- a/scripts/build_helper.py
+++ b/scripts/build_helper.py
@@ -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')