From b4c7cac8a2f1a50542df723458da59e6063b6b89 Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Sat, 4 Oct 2025 07:50:34 +0100 Subject: xbmk: rename the "dry" variable to if_not_dry_run and add a line break where it is used now it is essentially a macro of sorts, used in terms of syntax, to mean the same as: if [ "$dry" != ":" ]; do thing fi in this case, we say: $if_not_dry_build \ thing yes. macros in sh are a thing. Signed-off-by: Leah Rowe --- config/data/pico-serprog/mkhelper.cfg | 2 +- config/data/stm32-vserprog/mkhelper.cfg | 2 +- include/rom.sh | 56 ++++++++++++++++--------- include/tree.sh | 74 ++++++++++++++++++++------------- 4 files changed, 84 insertions(+), 50 deletions(-) diff --git a/config/data/pico-serprog/mkhelper.cfg b/config/data/pico-serprog/mkhelper.cfg index 982c365b..5a4546a6 100644 --- a/config/data/pico-serprog/mkhelper.cfg +++ b/config/data/pico-serprog/mkhelper.cfg @@ -4,4 +4,4 @@ sersrc="src/pico-serprog" serx="$sersrc/build/pico_serprog.uf2" picosdk="src/pico-sdk" serdir="$picosdk/src/boards/include/boards" -premake="$dry eval fx_ \"buildser pico\" x_ basename -as .h \"\$serdir/\"*.h" +premake="$if_not_dry_build eval fx_ \"buildser pico\" x_ basename -as .h \"\$serdir/\"*.h" diff --git a/config/data/stm32-vserprog/mkhelper.cfg b/config/data/stm32-vserprog/mkhelper.cfg index bb2189a6..26ea5acd 100644 --- a/config/data/stm32-vserprog/mkhelper.cfg +++ b/config/data/stm32-vserprog/mkhelper.cfg @@ -3,4 +3,4 @@ sersrc="src/stm32-vserprog" serx="$sersrc/stm32-vserprog.hex" serdir="$sersrc/boards" -mkhelper="$dry eval fx_ \"buildser stm32\" x_ basename -as .h \"\$serdir/\"*.h" +mkhelper="$if_not_dry_build eval fx_ \"buildser stm32\" x_ basename -as .h \"\$serdir/\"*.h" diff --git a/include/rom.sh b/include/rom.sh index 987ead6a..4de49eee 100644 --- a/include/rom.sh +++ b/include/rom.sh @@ -25,7 +25,7 @@ buildser() copyps1bios() { - if [ "$dry" = ":" ]; then + if [ "$if_not_dry_build" = ":" ]; then return 0 fi @@ -45,16 +45,16 @@ mkpayload_grub() grub_modules="" grub_install_modules="" - if [ "$dry" = ":" ]; then + if [ "$if_not_dry_build" = ":" ]; then return 0 fi . "$grubdata/module/$tree" || \ err "Can't read '$grubdata/module/$tree'" "mkpayload_grub" "$@" - $dry x_ rm -f "$srcdir/grub.elf" + x_ rm -f "$srcdir/grub.elf" - $dry x_ "$srcdir/grub-mkstandalone" \ + x_ "$srcdir/grub-mkstandalone" \ --grub-mkimage="$srcdir/grub-mkimage" \ -O i386-coreboot -o "$srcdir/grub.elf" -d "${srcdir}/grub-core/" \ --fonts= --themes= --locales= --modules="$grub_modules" \ @@ -69,7 +69,9 @@ corebootpremake() return 0 fi - $dry cook_coreboot_config + $if_not_dry_build \ + cook_coreboot_config + fx_ check_coreboot_util printf "cbfstool\nifdtool\n" printf "%s\n" "${version%%-*}" > "$srcdir/.coreboot-version" || \ @@ -131,7 +133,8 @@ coreboot_pad_one_byte() return 0 fi - $dry pad_one_byte "$srcdir/build/coreboot.rom" + $if_not_dry_build \ + pad_one_byte "$srcdir/build/coreboot.rom" } mkcorebootbin() @@ -140,8 +143,11 @@ mkcorebootbin() return 0 fi - $dry check_coreboot_util cbfstool - $dry check_coreboot_util ifdtool + $if_not_dry_build \ + check_coreboot_util cbfstool + + $if_not_dry_build \ + check_coreboot_util ifdtool for y in "$target_dir/config"/*; do defconfig="$y" @@ -175,8 +181,11 @@ mkcorebootbin_real() fi elfrom="$elfrom/coreboot.rom" - $dry x_ cp "$elfrom" "$tmprom" - $dry unpad_one_byte "$tmprom" + $if_not_dry_build \ + x_ cp "$elfrom" "$tmprom" + + $if_not_dry_build \ + unpad_one_byte "$tmprom" if [ -n "$payload_uboot" ] && [ "$payload_uboot" != "amd64" ] && \ [ "$payload_uboot" != "i386" ] && [ "$payload_uboot" != "arm64" ] @@ -196,8 +205,9 @@ mkcorebootbin_real() payload_seabios="y" fi if [ "$payload_seabios" = "y" ] && [ "$payload_uboot" = "arm64" ]; then - $dry err "$target: U-Boot(arm) and SeaBIOS/GRUB both enabled" \ - "mkcorebootbin_real" "$@" + $if_not_dry_build \ + err "$target: U-Boot arm and SeaBIOS/GRUB both enabled" \ + "mkcorebootbin_real" "$@" fi if [ -z "$grub_scan_disk" ]; then @@ -222,18 +232,21 @@ mkcorebootbin_real() payload_grubsea="n" fi - if $dry grep "CONFIG_PAYLOAD_NONE=y" "$defconfig"; then + if $if_not_dry_build grep "CONFIG_PAYLOAD_NONE=y" "$defconfig"; then if [ "$payload_seabios" = "y" ]; then pname="seabios" - $dry add_seabios + $if_not_dry_build \ + add_seabios fi if [ "$payload_uboot" = "arm64" ]; then pname="uboot" - $dry add_uboot + $if_not_dry_build \ + add_uboot fi else pname="custom" - $dry cprom + $if_not_dry_build \ + cprom fi; : } @@ -250,7 +263,8 @@ add_seabios() # we must add u-boot first, because it's added as a flat # binary at a specific offset for secondary program loader - $dry add_uboot + $if_not_dry_build \ + add_uboot fi _seabioself="elf/seabios/default/default/$initmode/bios.bin.elf" @@ -465,7 +479,11 @@ mkcoreboottar() { if [ "$target" != "$tree" ] && [ "$XBMK_RELEASE" = "y" ] && \ [ "$release" != "n" ]; then - $dry mkrom_tarball "bin/$target" && \ - $dry x_ ./mk inject "bin/${relname}_${target}.tar.xz" nuke; : + + $if_not_dry_build \ + mkrom_tarball "bin/$target" + + $if_not_dry_build \ + x_ ./mk inject "bin/${relname}_${target}.tar.xz" nuke fi } diff --git a/include/tree.sh b/include/tree.sh index 6d2d2f7c..f5127a6e 100644 --- a/include/tree.sh +++ b/include/tree.sh @@ -33,7 +33,7 @@ cmakedir="" defconfig="" postmake="" mkhelpercfg="" -dry="" +if_not_dry_build="" dest_dir="" mdir="" cleanargs="" @@ -66,11 +66,11 @@ trees() -d) # -d is similar to -b, except that # a large number of operations will be - # skipped. these are "dry build" scenarios + # skipped. these are "if_not_dry_build build" scenarios # where only a subset of build tasks are done, - # and $dry is prefixed to skipped commands + # and $if_not_dry_build is prefixed to skipped commands - dry=":" + if_not_dry_build=":" ;; -b) : ;; -u) mode="oldconfig" ;; @@ -79,11 +79,11 @@ trees() -x) mode="crossgcc-clean" ;; -f) # download source code for a project do_make="n" # lets us know not to build anything - dry=":" + if_not_dry_build=":" ;; -F) # same as -F, but don't skip git fetch/pull on cache do_make="n" # lets us know not to build anything - dry=":" + if_not_dry_build=":" forcepull="y" ;; -s) mode="savedefconfig" ;; @@ -146,7 +146,7 @@ build_project() if ! configure_project "$configdir"; then return 0 elif [ -f "$listfile" ]; then - if ! $dry elfcheck; then + if ! $if_not_dry_build elfcheck; then return 0 fi fi @@ -160,7 +160,8 @@ build_project() fi if [ -z "$mode" ]; then - $dry copy_elf; : + $if_not_dry_build \ + copy_elf; : fi } @@ -234,7 +235,8 @@ handle_defconfig() if [ -z "$mode" ]; then for _xarch in $xarch; do if [ -n "$_xarch" ]; then - $dry check_cross_compiler "$_xarch" + $if_not_dry_build \ + check_cross_compiler "$_xarch" fi done; : fi @@ -242,7 +244,8 @@ handle_defconfig() handle_makefile if [ -z "$mode" ]; then - $dry copy_elf + $if_not_dry_build \ + copy_elf fi done; : } @@ -333,7 +336,8 @@ configure_project() fi if [ -z "$mode" ]; then - $dry build_dependencies; : + $if_not_dry_build \ + build_dependencies fi mdir="$xbmkpwd/config/submodule/$project" @@ -366,14 +370,16 @@ build_dependencies() bd_tree="${bd##*/}" if [ -z "$bd_project" ]; then - $dry err "$project/$tree: !bd '$bd'" \ - "build_dependencies" "$@" + $if_not_dry_build \ + err "$project/$tree: !bd '$bd'" \ + "build_dependencies" "$@" fi if [ "${bd##*/}" = "$bd" ]; then bd_tree="" fi if [ -n "$bd_project" ]; then - $dry x_ ./mk -b $bd_project $bd_tree; : + $if_not_dry_build \ + x_ ./mk -b $bd_project $bd_tree; : fi done; : } @@ -607,14 +613,15 @@ gnu_setver() check_defconfig() { if [ ! -f "$defconfig" ]; then - $dry err "$project/$target: no config" "check_defconfig" "$@" + $if_not_dry_build \ + err "$project/$target: no config" "check_defconfig" "$@" fi dest_dir="$elfdir/$tree/$target/${defconfig#"$target_dir/config/"}" # skip build if a previous one exists: - if ! $dry elfcheck; then + if ! $if_not_dry_build elfcheck; then return 1 fi } @@ -628,8 +635,9 @@ elfcheck() handle_makefile() { - if $dry check_makefile "$srcdir"; then - $dry x_ make -C "$srcdir" $cleanargs clean + if $if_not_dry_build check_makefile "$srcdir"; then + $if_not_dry_build \ + x_ make -C "$srcdir" $cleanargs clean fi if [ -f "$defconfig" ]; then @@ -646,12 +654,14 @@ handle_makefile() fi if [ "${mode%config}" != "$mode" ]; then - $dry x_ cp "$srcdir/$_copy" "$defconfig"; : + $if_not_dry_build \ + x_ cp "$srcdir/$_copy" "$defconfig"; : fi if [ -e "$srcdir/.git" ] && [ "$project" = "u-boot" ] && \ [ "$mode" = "distclean" ]; then - $dry x_ git -C "$srcdir" $cleanargs clean -fdx; : + $if_not_dry_build \ + x_ git -C "$srcdir" $cleanargs clean -fdx; : fi } @@ -661,16 +671,18 @@ run_make_command() x_ $premake fi - if $dry check_cmake "$srcdir"; then + if $if_not_dry_build check_cmake "$srcdir"; then if [ -z "$mode" ]; then - $dry check_autoconf "$srcdir" + $if_not_dry_build \ + check_autoconf "$srcdir" fi fi - if ! $dry check_makefile "$srcdir"; then + if ! $if_not_dry_build check_makefile "$srcdir"; then return 1 fi - $dry x_ make -C "$srcdir" $mode -j$XBMK_THREADS $makeargs + $if_not_dry_build \ + x_ make -C "$srcdir" $mode -j$XBMK_THREADS $makeargs if [ -z "$mode" ]; then x_ $mkhelper @@ -681,20 +693,24 @@ run_make_command() fi if [ "$mode" = "clean" ]; then - $dry make -C "$srcdir" $cleanargs distclean || \ - $dry x_ make -C "$srcdir" $cleanargs clean; : + $if_not_dry_build \ + make -C "$srcdir" $cleanargs distclean || \ + $if_not_dry_build \ + x_ make -C "$srcdir" $cleanargs clean; : fi } check_cmake() { if [ -n "$cmakedir" ]; then - if ! $dry check_makefile "$1"; then + if ! $if_not_dry_build check_makefile "$1"; then if ! cmake -B "$1" "$1/$cmakedir"; then - $dry x_ check_makefile "$1" + $if_not_dry_build \ + x_ check_makefile "$1" fi fi - $dry x_ check_makefile "$1"; : + $if_not_dry_build \ + x_ check_makefile "$1"; : fi } -- cgit v1.2.1