diff --git a/scripts/build/package-gpu-libs-darwin_test.sh b/scripts/build/package-gpu-libs-darwin_test.sh new file mode 100644 index 000000000..2afbb34ae --- /dev/null +++ b/scripts/build/package-gpu-libs-darwin_test.sh @@ -0,0 +1,19 @@ +#!/bin/bash +# Darwin uses system GPU frameworks and ships Bash 3.2 without associative arrays. +set -euo pipefail +SCRIPT="$(dirname "$(realpath "$0")")/package-gpu-libs.sh" +WORK=$(mktemp -d) +trap 'rm -rf "$WORK"' EXIT +uname() { echo Darwin; } +declare() { + if [[ "${1:-}" == -A ]]; then + echo 'Bash 3.2 does not support declare -A' >&2 + return 2 + fi + builtin declare "$@" +} +export BUILD_TYPE=metal +source "$SCRIPT" "$WORK/lib" +package_gpu_libs +test -z "$(find "$WORK" -type f -print)" +echo 'PASS: Darwin does not load the Linux GPU packager' diff --git a/scripts/build/package-gpu-libs.sh b/scripts/build/package-gpu-libs.sh index d2d354123..d46e1ddaa 100755 --- a/scripts/build/package-gpu-libs.sh +++ b/scripts/build/package-gpu-libs.sh @@ -15,6 +15,16 @@ set -e +# macOS uses system GPU frameworks; this packager handles Linux ELF libraries. +# Return before Bash 3.2 encounters the associative arrays used below. +if [[ "$(uname -s)" == Darwin ]]; then + package_gpu_libs() { + echo "Detected Darwin; no Linux GPU libraries to package" + } + export -f package_gpu_libs + return 0 2>/dev/null || exit 0 +fi + TARGET_LIB_DIR="${1:-./lib}" # Create target directory if it doesn't exist