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 exit 1
fi fi
# Map Rust target -> Android ABI -> NDK toolchain target # Parallel arrays — bash 3.2 compatible (no declare -A)
declare -A TARGET_ABI=( TARGETS=( "aarch64-linux-android" "armv7-linux-androideabi" "x86_64-linux-android" )
["aarch64-linux-android"]="arm64-v8a" TARGET_ABIS=( "arm64-v8a" "armeabi-v7a" "x86_64" )
["armv7-linux-androideabi"]="armeabi-v7a" TARGET_CCS=( "aarch64-linux-android21-clang" "armv7a-linux-androideabi21-clang" "x86_64-linux-android21-clang" )
["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"
)
# Find the NDK toolchain bin directory # Find the NDK toolchain bin directory
TOOLCHAIN="$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin" TOOLCHAIN="$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin"
@@ -60,9 +52,10 @@ echo " NDK: $ANDROID_NDK_HOME"
echo " Crates: ${CRATES[*]}" echo " Crates: ${CRATES[*]}"
echo "" echo ""
for target in "${!TARGET_ABI[@]}"; do for i in "${!TARGETS[@]}"; do
abi="${TARGET_ABI["$target"]}" target="${TARGETS[$i]}"
cc="${TARGET_CC["$target"]}" abi="${TARGET_ABIS[$i]}"
cc="${TARGET_CCS[$i]}"
echo " ── $target ($abi) ──" echo " ── $target ($abi) ──"
# Set linker/compiler for this target via CARGO_TARGET env vars # Set linker/compiler for this target via CARGO_TARGET env vars
@@ -96,8 +89,8 @@ for target in "${!TARGET_ABI[@]}"; do
done done
echo "==> Done. Libraries:" echo "==> Done. Libraries:"
for target in "${!TARGET_ABI[@]}"; do for i in "${!TARGETS[@]}"; do
abi="${TARGET_ABI["$target"]}" abi="${TARGET_ABIS[$i]}"
echo " $abi:" echo " $abi:"
ls -lh "$OUT_DIR/$abi/"*.so ls -lh "$OUT_DIR/$abi/"*.so
done done
+8 -14
View File
@@ -21,22 +21,16 @@ TARGETS=(
x86_64-apple-ios # Simulator (Intel) x86_64-apple-ios # Simulator (Intel)
) )
# Libraries to build and package # Libraries to build and package (parallel arrays — bash 3.2 compatible)
declare -A LIB_NAMES=( CRATES=( "salvium-crypto" "salvium-ffi" )
["salvium-crypto"]="libsalvium_crypto" LIB_NAMES=( "libsalvium_crypto" "libsalvium_ffi" )
["salvium-ffi"]="libsalvium_ffi" FRAMEWORK_NAMES=( "SalviumCrypto" "SalviumFfi" )
)
declare -A FRAMEWORK_NAMES=(
["salvium-crypto"]="SalviumCrypto"
["salvium-ffi"]="SalviumFfi"
)
echo "==> Building Salvium libraries for iOS targets..." echo "==> Building Salvium libraries for iOS targets..."
for target in "${TARGETS[@]}"; do for target in "${TARGETS[@]}"; do
echo " -> $target" echo " -> $target"
for crate in "${!LIB_NAMES[@]}"; do for crate in "${CRATES[@]}"; do
cargo build --release \ cargo build --release \
--target "$target" \ --target "$target" \
-p "$crate" \ -p "$crate" \
@@ -47,9 +41,9 @@ done
echo "==> Creating xcframeworks..." echo "==> Creating xcframeworks..."
mkdir -p "$WORK_DIR" mkdir -p "$WORK_DIR"
for crate in "${!LIB_NAMES[@]}"; do for i in "${!CRATES[@]}"; do
lib="${LIB_NAMES["$crate"]}" lib="${LIB_NAMES[$i]}"
framework="${FRAMEWORK_NAMES["$crate"]}" framework="${FRAMEWORK_NAMES[$i]}"
echo " -> $framework.xcframework" echo " -> $framework.xcframework"