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 <leah@libreboot.org>
This commit is contained in:
Leah Rowe
2025-10-04 07:50:34 +01:00
parent 9f84bd4f34
commit b4c7cac8a2
4 changed files with 84 additions and 50 deletions
+1 -1
View File
@@ -4,4 +4,4 @@ sersrc="src/pico-serprog"
serx="$sersrc/build/pico_serprog.uf2" serx="$sersrc/build/pico_serprog.uf2"
picosdk="src/pico-sdk" picosdk="src/pico-sdk"
serdir="$picosdk/src/boards/include/boards" 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"
+1 -1
View File
@@ -3,4 +3,4 @@
sersrc="src/stm32-vserprog" sersrc="src/stm32-vserprog"
serx="$sersrc/stm32-vserprog.hex" serx="$sersrc/stm32-vserprog.hex"
serdir="$sersrc/boards" 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"
+37 -19
View File
@@ -25,7 +25,7 @@ buildser()
copyps1bios() copyps1bios()
{ {
if [ "$dry" = ":" ]; then if [ "$if_not_dry_build" = ":" ]; then
return 0 return 0
fi fi
@@ -45,16 +45,16 @@ mkpayload_grub()
grub_modules="" grub_modules=""
grub_install_modules="" grub_install_modules=""
if [ "$dry" = ":" ]; then if [ "$if_not_dry_build" = ":" ]; then
return 0 return 0
fi fi
. "$grubdata/module/$tree" || \ . "$grubdata/module/$tree" || \
err "Can't read '$grubdata/module/$tree'" "mkpayload_grub" "$@" 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" \ --grub-mkimage="$srcdir/grub-mkimage" \
-O i386-coreboot -o "$srcdir/grub.elf" -d "${srcdir}/grub-core/" \ -O i386-coreboot -o "$srcdir/grub.elf" -d "${srcdir}/grub-core/" \
--fonts= --themes= --locales= --modules="$grub_modules" \ --fonts= --themes= --locales= --modules="$grub_modules" \
@@ -69,7 +69,9 @@ corebootpremake()
return 0 return 0
fi fi
$dry cook_coreboot_config $if_not_dry_build \
cook_coreboot_config
fx_ check_coreboot_util printf "cbfstool\nifdtool\n" fx_ check_coreboot_util printf "cbfstool\nifdtool\n"
printf "%s\n" "${version%%-*}" > "$srcdir/.coreboot-version" || \ printf "%s\n" "${version%%-*}" > "$srcdir/.coreboot-version" || \
@@ -131,7 +133,8 @@ coreboot_pad_one_byte()
return 0 return 0
fi fi
$dry pad_one_byte "$srcdir/build/coreboot.rom" $if_not_dry_build \
pad_one_byte "$srcdir/build/coreboot.rom"
} }
mkcorebootbin() mkcorebootbin()
@@ -140,8 +143,11 @@ mkcorebootbin()
return 0 return 0
fi fi
$dry check_coreboot_util cbfstool $if_not_dry_build \
$dry check_coreboot_util ifdtool check_coreboot_util cbfstool
$if_not_dry_build \
check_coreboot_util ifdtool
for y in "$target_dir/config"/*; do for y in "$target_dir/config"/*; do
defconfig="$y" defconfig="$y"
@@ -175,8 +181,11 @@ mkcorebootbin_real()
fi fi
elfrom="$elfrom/coreboot.rom" elfrom="$elfrom/coreboot.rom"
$dry x_ cp "$elfrom" "$tmprom" $if_not_dry_build \
$dry unpad_one_byte "$tmprom" x_ cp "$elfrom" "$tmprom"
$if_not_dry_build \
unpad_one_byte "$tmprom"
if [ -n "$payload_uboot" ] && [ "$payload_uboot" != "amd64" ] && \ if [ -n "$payload_uboot" ] && [ "$payload_uboot" != "amd64" ] && \
[ "$payload_uboot" != "i386" ] && [ "$payload_uboot" != "arm64" ] [ "$payload_uboot" != "i386" ] && [ "$payload_uboot" != "arm64" ]
@@ -196,8 +205,9 @@ mkcorebootbin_real()
payload_seabios="y" payload_seabios="y"
fi fi
if [ "$payload_seabios" = "y" ] && [ "$payload_uboot" = "arm64" ]; then if [ "$payload_seabios" = "y" ] && [ "$payload_uboot" = "arm64" ]; then
$dry err "$target: U-Boot(arm) and SeaBIOS/GRUB both enabled" \ $if_not_dry_build \
"mkcorebootbin_real" "$@" err "$target: U-Boot arm and SeaBIOS/GRUB both enabled" \
"mkcorebootbin_real" "$@"
fi fi
if [ -z "$grub_scan_disk" ]; then if [ -z "$grub_scan_disk" ]; then
@@ -222,18 +232,21 @@ mkcorebootbin_real()
payload_grubsea="n" payload_grubsea="n"
fi 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 if [ "$payload_seabios" = "y" ]; then
pname="seabios" pname="seabios"
$dry add_seabios $if_not_dry_build \
add_seabios
fi fi
if [ "$payload_uboot" = "arm64" ]; then if [ "$payload_uboot" = "arm64" ]; then
pname="uboot" pname="uboot"
$dry add_uboot $if_not_dry_build \
add_uboot
fi fi
else else
pname="custom" pname="custom"
$dry cprom $if_not_dry_build \
cprom
fi; : fi; :
} }
@@ -250,7 +263,8 @@ add_seabios()
# we must add u-boot first, because it's added as a flat # we must add u-boot first, because it's added as a flat
# binary at a specific offset for secondary program loader # binary at a specific offset for secondary program loader
$dry add_uboot $if_not_dry_build \
add_uboot
fi fi
_seabioself="elf/seabios/default/default/$initmode/bios.bin.elf" _seabioself="elf/seabios/default/default/$initmode/bios.bin.elf"
@@ -465,7 +479,11 @@ mkcoreboottar()
{ {
if [ "$target" != "$tree" ] && [ "$XBMK_RELEASE" = "y" ] && \ if [ "$target" != "$tree" ] && [ "$XBMK_RELEASE" = "y" ] && \
[ "$release" != "n" ]; then [ "$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 fi
} }
+45 -29
View File
@@ -33,7 +33,7 @@ cmakedir=""
defconfig="" defconfig=""
postmake="" postmake=""
mkhelpercfg="" mkhelpercfg=""
dry="" if_not_dry_build=""
dest_dir="" dest_dir=""
mdir="" mdir=""
cleanargs="" cleanargs=""
@@ -66,11 +66,11 @@ trees()
-d) -d)
# -d is similar to -b, except that # -d is similar to -b, except that
# a large number of operations will be # 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, # 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) : ;; -b) : ;;
-u) mode="oldconfig" ;; -u) mode="oldconfig" ;;
@@ -79,11 +79,11 @@ trees()
-x) mode="crossgcc-clean" ;; -x) mode="crossgcc-clean" ;;
-f) # download source code for a project -f) # download source code for a project
do_make="n" # lets us know not to build anything 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 -F) # same as -F, but don't skip git fetch/pull on cache
do_make="n" # lets us know not to build anything do_make="n" # lets us know not to build anything
dry=":" if_not_dry_build=":"
forcepull="y" forcepull="y"
;; ;;
-s) mode="savedefconfig" ;; -s) mode="savedefconfig" ;;
@@ -146,7 +146,7 @@ build_project()
if ! configure_project "$configdir"; then if ! configure_project "$configdir"; then
return 0 return 0
elif [ -f "$listfile" ]; then elif [ -f "$listfile" ]; then
if ! $dry elfcheck; then if ! $if_not_dry_build elfcheck; then
return 0 return 0
fi fi
fi fi
@@ -160,7 +160,8 @@ build_project()
fi fi
if [ -z "$mode" ]; then if [ -z "$mode" ]; then
$dry copy_elf; : $if_not_dry_build \
copy_elf; :
fi fi
} }
@@ -234,7 +235,8 @@ handle_defconfig()
if [ -z "$mode" ]; then if [ -z "$mode" ]; then
for _xarch in $xarch; do for _xarch in $xarch; do
if [ -n "$_xarch" ]; then if [ -n "$_xarch" ]; then
$dry check_cross_compiler "$_xarch" $if_not_dry_build \
check_cross_compiler "$_xarch"
fi fi
done; : done; :
fi fi
@@ -242,7 +244,8 @@ handle_defconfig()
handle_makefile handle_makefile
if [ -z "$mode" ]; then if [ -z "$mode" ]; then
$dry copy_elf $if_not_dry_build \
copy_elf
fi fi
done; : done; :
} }
@@ -333,7 +336,8 @@ configure_project()
fi fi
if [ -z "$mode" ]; then if [ -z "$mode" ]; then
$dry build_dependencies; : $if_not_dry_build \
build_dependencies
fi fi
mdir="$xbmkpwd/config/submodule/$project" mdir="$xbmkpwd/config/submodule/$project"
@@ -366,14 +370,16 @@ build_dependencies()
bd_tree="${bd##*/}" bd_tree="${bd##*/}"
if [ -z "$bd_project" ]; then if [ -z "$bd_project" ]; then
$dry err "$project/$tree: !bd '$bd'" \ $if_not_dry_build \
"build_dependencies" "$@" err "$project/$tree: !bd '$bd'" \
"build_dependencies" "$@"
fi fi
if [ "${bd##*/}" = "$bd" ]; then if [ "${bd##*/}" = "$bd" ]; then
bd_tree="" bd_tree=""
fi fi
if [ -n "$bd_project" ]; then 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 fi
done; : done; :
} }
@@ -607,14 +613,15 @@ gnu_setver()
check_defconfig() check_defconfig()
{ {
if [ ! -f "$defconfig" ]; then if [ ! -f "$defconfig" ]; then
$dry err "$project/$target: no config" "check_defconfig" "$@" $if_not_dry_build \
err "$project/$target: no config" "check_defconfig" "$@"
fi fi
dest_dir="$elfdir/$tree/$target/${defconfig#"$target_dir/config/"}" dest_dir="$elfdir/$tree/$target/${defconfig#"$target_dir/config/"}"
# skip build if a previous one exists: # skip build if a previous one exists:
if ! $dry elfcheck; then if ! $if_not_dry_build elfcheck; then
return 1 return 1
fi fi
} }
@@ -628,8 +635,9 @@ elfcheck()
handle_makefile() handle_makefile()
{ {
if $dry check_makefile "$srcdir"; then if $if_not_dry_build check_makefile "$srcdir"; then
$dry x_ make -C "$srcdir" $cleanargs clean $if_not_dry_build \
x_ make -C "$srcdir" $cleanargs clean
fi fi
if [ -f "$defconfig" ]; then if [ -f "$defconfig" ]; then
@@ -646,12 +654,14 @@ handle_makefile()
fi fi
if [ "${mode%config}" != "$mode" ]; then if [ "${mode%config}" != "$mode" ]; then
$dry x_ cp "$srcdir/$_copy" "$defconfig"; : $if_not_dry_build \
x_ cp "$srcdir/$_copy" "$defconfig"; :
fi fi
if [ -e "$srcdir/.git" ] && [ "$project" = "u-boot" ] && \ if [ -e "$srcdir/.git" ] && [ "$project" = "u-boot" ] && \
[ "$mode" = "distclean" ]; then [ "$mode" = "distclean" ]; then
$dry x_ git -C "$srcdir" $cleanargs clean -fdx; : $if_not_dry_build \
x_ git -C "$srcdir" $cleanargs clean -fdx; :
fi fi
} }
@@ -661,16 +671,18 @@ run_make_command()
x_ $premake x_ $premake
fi fi
if $dry check_cmake "$srcdir"; then if $if_not_dry_build check_cmake "$srcdir"; then
if [ -z "$mode" ]; then if [ -z "$mode" ]; then
$dry check_autoconf "$srcdir" $if_not_dry_build \
check_autoconf "$srcdir"
fi fi
fi fi
if ! $dry check_makefile "$srcdir"; then if ! $if_not_dry_build check_makefile "$srcdir"; then
return 1 return 1
fi 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 if [ -z "$mode" ]; then
x_ $mkhelper x_ $mkhelper
@@ -681,20 +693,24 @@ run_make_command()
fi fi
if [ "$mode" = "clean" ]; then if [ "$mode" = "clean" ]; then
$dry make -C "$srcdir" $cleanargs distclean || \ $if_not_dry_build \
$dry x_ make -C "$srcdir" $cleanargs clean; : make -C "$srcdir" $cleanargs distclean || \
$if_not_dry_build \
x_ make -C "$srcdir" $cleanargs clean; :
fi fi
} }
check_cmake() check_cmake()
{ {
if [ -n "$cmakedir" ]; then 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 if ! cmake -B "$1" "$1/$cmakedir"; then
$dry x_ check_makefile "$1" $if_not_dry_build \
x_ check_makefile "$1"
fi fi
fi fi
$dry x_ check_makefile "$1"; : $if_not_dry_build \
x_ check_makefile "$1"; :
fi fi
} }