Fix iOS release build: replace bash associative arrays with indexed arrays

macOS GitHub Actions runners ship bash 3.2, which does not support
  declare -A (requires bash 4.0+). Rewrote build-ios.sh and
  build-android.sh to use parallel indexed arrays instead.
This commit is contained in:
Matt Hess
2026-02-25 03:59:29 +00:00
parent 43840ac0d2
commit 28fbd223c7
2 changed files with 18 additions and 31 deletions
+10 -17
View File
@@ -26,18 +26,10 @@ if [ -z "${ANDROID_NDK_HOME:-}" ]; then
exit 1
fi
# Map Rust target -> Android ABI -> NDK toolchain target
declare -A TARGET_ABI=(
["aarch64-linux-android"]="arm64-v8a"
["armv7-linux-androideabi"]="armeabi-v7a"
["x86_64-linux-android"]="x86_64"
)
declare -A TARGET_CC=(
["aarch64-linux-android"]="aarch64-linux-android21-clang"
["armv7-linux-androideabi"]="armv7a-linux-androideabi21-clang"
["x86_64-linux-android"]="x86_64-linux-android21-clang"
)
# Parallel arrays — bash 3.2 compatible (no declare -A)
TARGETS=( "aarch64-linux-android" "armv7-linux-androideabi" "x86_64-linux-android" )
TARGET_ABIS=( "arm64-v8a" "armeabi-v7a" "x86_64" )
TARGET_CCS=( "aarch64-linux-android21-clang" "armv7a-linux-androideabi21-clang" "x86_64-linux-android21-clang" )
# Find the NDK toolchain bin directory
TOOLCHAIN="$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin"
@@ -60,9 +52,10 @@ echo " NDK: $ANDROID_NDK_HOME"
echo " Crates: ${CRATES[*]}"
echo ""
for target in "${!TARGET_ABI[@]}"; do
abi="${TARGET_ABI["$target"]}"
cc="${TARGET_CC["$target"]}"
for i in "${!TARGETS[@]}"; do
target="${TARGETS[$i]}"
abi="${TARGET_ABIS[$i]}"
cc="${TARGET_CCS[$i]}"
echo " ── $target ($abi) ──"
# Set linker/compiler for this target via CARGO_TARGET env vars
@@ -96,8 +89,8 @@ for target in "${!TARGET_ABI[@]}"; do
done
echo "==> Done. Libraries:"
for target in "${!TARGET_ABI[@]}"; do
abi="${TARGET_ABI["$target"]}"
for i in "${!TARGETS[@]}"; do
abi="${TARGET_ABIS[$i]}"
echo " $abi:"
ls -lh "$OUT_DIR/$abi/"*.so
done
+8 -14
View File
@@ -21,22 +21,16 @@ TARGETS=(
x86_64-apple-ios # Simulator (Intel)
)
# Libraries to build and package
declare -A LIB_NAMES=(
["salvium-crypto"]="libsalvium_crypto"
["salvium-ffi"]="libsalvium_ffi"
)
declare -A FRAMEWORK_NAMES=(
["salvium-crypto"]="SalviumCrypto"
["salvium-ffi"]="SalviumFfi"
)
# Libraries to build and package (parallel arrays — bash 3.2 compatible)
CRATES=( "salvium-crypto" "salvium-ffi" )
LIB_NAMES=( "libsalvium_crypto" "libsalvium_ffi" )
FRAMEWORK_NAMES=( "SalviumCrypto" "SalviumFfi" )
echo "==> Building Salvium libraries for iOS targets..."
for target in "${TARGETS[@]}"; do
echo " -> $target"
for crate in "${!LIB_NAMES[@]}"; do
for crate in "${CRATES[@]}"; do
cargo build --release \
--target "$target" \
-p "$crate" \
@@ -47,9 +41,9 @@ done
echo "==> Creating xcframeworks..."
mkdir -p "$WORK_DIR"
for crate in "${!LIB_NAMES[@]}"; do
lib="${LIB_NAMES["$crate"]}"
framework="${FRAMEWORK_NAMES["$crate"]}"
for i in "${!CRATES[@]}"; do
lib="${LIB_NAMES[$i]}"
framework="${FRAMEWORK_NAMES[$i]}"
echo " -> $framework.xcframework"