Support macOS Bash 3.2 in compile scripts

This commit is contained in:
Armel FAUVEAU committed 2026-09-08 19:25:22 +02:00
1 parent dbb9d42d2d
commit 43e9e1ec67
2 files changed
+11 -8

No files matched your search

+3 -3
View File
@@ -33,7 +33,7 @@ if [ "${#ALL_APPS[@]}" -eq 0 ]; then
fi fi
# --- select targets --- # --- select targets ---
if [ "$#" -eq 0 ] || [ "${1,,}" = "all" ]; then if [ "$#" -eq 0 ] || [[ "${1:-}" == [Aa][Ll][Ll] ]]; then
TARGETS=("${ALL_APPS[@]}") TARGETS=("${ALL_APPS[@]}")
else else
TARGETS=() TARGETS=()
@@ -56,7 +56,7 @@ mkdir -p "$OUT_DIR"
# Give the container a pseudo-TTY when we are interactive, so build.sh's # Give the container a pseudo-TTY when we are interactive, so build.sh's
# single-line [k/3] progress refreshes in place (same trick as the firmware # single-line [k/3] progress refreshes in place (same trick as the firmware
# build gives Ninja). Batch/redirected runs stay plain and line-oriented. # build gives Ninja). Batch/redirected runs stay plain and line-oriented.
TTY_ARGS=(); [[ -t 1 ]] && TTY_ARGS=(-t) TTY_ARG=""; [[ -t 1 ]] && TTY_ARG="-t"
echo echo
echo "🚀 Building overlay apps" echo "🚀 Building overlay apps"
@@ -69,7 +69,7 @@ fail=0
read_u32le() { od -An -tx1 -j"$2" -N4 "$1" | awk '{printf "0x%s%s%s%s",$4,$3,$2,$1}'; } read_u32le() { od -An -tx1 -j"$2" -N4 "$1" | awk '{printf "0x%s%s%s%s",$4,$3,$2,$1}'; }
for app in "${TARGETS[@]}"; do for app in "${TARGETS[@]}"; do
if docker run --rm "${TTY_ARGS[@]}" -u "$(id -u):$(id -g)" \ if docker run --rm ${TTY_ARG:+"$TTY_ARG"} -u "$(id -u):$(id -g)" \
-v "$PWD":/work -w "/work/$APPS_DIR/$app" \ -v "$PWD":/work -w "/work/$APPS_DIR/$app" \
-e PATH="/opt/toolchain/bin:/usr/bin:/bin" -e APP_VMA="$APP_VMA" \ -e PATH="/opt/toolchain/bin:/usr/bin:/bin" -e APP_VMA="$APP_VMA" \
"$IMAGE" bash ./build.sh; then "$IMAGE" bash ./build.sh; then
+8 -5
View File
@@ -63,29 +63,32 @@ RESULT_RAM_SIZES=()
run_preset_build() { run_preset_build() {
local preset="$1" local preset="$1"
local -a docker_tty_args=() local docker_tty_arg=""
# Give Ninja a pseudo-terminal for an interactive single-preset build. This # Give Ninja a pseudo-terminal for an interactive single-preset build. This
# lets it refresh its [current/total] progress on one line. Batch/redirected # lets it refresh its [current/total] progress on one line. Batch/redirected
# builds keep plain line-oriented output suitable for logs and CI. # builds keep plain line-oriented output suitable for logs and CI.
if (( INTERACTIVE && ! QUIET )); then if (( INTERACTIVE && ! QUIET )); then
docker_tty_args=(-t) docker_tty_arg="-t"
fi fi
docker run --rm "${docker_tty_args[@]}" \ # The ${var:+...} and ${array[@]+...} forms avoid expanding an empty array,
# which Bash 3.2 treats as an unbound variable when nounset is enabled.
docker run --rm ${docker_tty_arg:+"$docker_tty_arg"} \
-u "$(id -u):$(id -g)" \ -u "$(id -u):$(id -g)" \
-v "$PWD":/src -w /src "$IMAGE" \ -v "$PWD":/src -w /src "$IMAGE" \
bash -c 'which arm-none-eabi-gcc && arm-none-eabi-gcc --version && bash -c 'which arm-none-eabi-gcc && arm-none-eabi-gcc --version &&
cmake --fresh --preset "$1" "${@:2}" && cmake --fresh --preset "$1" "${@:2}" &&
cmake --build --preset "$1" -j' \ cmake --build --preset "$1" -j' \
bash "$preset" "${EXTRA_ARGS[@]}" bash "$preset" ${EXTRA_ARGS[@]+"${EXTRA_ARGS[@]}"}
} }
build_preset() { build_preset() {
local preset="$1" local preset="$1"
local preset_slug log_file bin_file flash_size ram_size status local preset_slug log_file bin_file flash_size ram_size status
preset_slug="${preset,,}" # macOS ships Bash 3.2, which does not support Bash 4's ${var,,} syntax.
preset_slug="$(printf '%s' "$preset" | tr '[:upper:]' '[:lower:]')"
log_file="$(mktemp)" log_file="$(mktemp)"
bin_file="" bin_file=""