The native sink corpus is staged into the test target's resources by scripts/build-xcframework.sh (not committed), and the tests read it from Bundle.module, else from the repository. Each test prints a summary line (WAI-SINK …): the corpus's cases and calls through the C interface, the relay's verdicts per fragment, the refused requests of a fragment changed at the origin and their statuses, and the end-to-end and hidden sessions' outcomes. Co-Authored-By: Claude Opus 5.5 <[email protected]>
74 lines
3.4 KiB
Shell
Executable file
74 lines
3.4 KiB
Shell
Executable file
#!/usr/bin/env bash
|
|
# Build WaiFFI.xcframework: libwai (wai-rs, feature `native_sink`, no codec library) for every
|
|
# target the Swift package supports, with include/wai.h and a module map, into ../build/; and stage
|
|
# the native sink corpus into the tests' resources.
|
|
#
|
|
# scripts/build-xcframework.sh every slice
|
|
# WAI_SINK_SLICES="macos ios-sim" ... only those (macos, ios, ios-sim, tvos, tvos-sim)
|
|
#
|
|
# The phone, tablet and desktop targets are tier 2 and build with the repository's pinned
|
|
# toolchain (rust-toolchain.toml) once their standard library is installed
|
|
# (`rustup target add aarch64-apple-ios aarch64-apple-ios-sim x86_64-apple-ios x86_64-apple-darwin`).
|
|
# The television
|
|
# targets are tier 3: their standard library is built from source with the nightly toolchain named
|
|
# by WAI_SINK_NIGHTLY (default nightly-2026-10-17), which needs its `rust-src` component; their
|
|
# simulator slice is arm64 alone.
|
|
set -euo pipefail
|
|
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
RS="$HERE/../wai-rs"
|
|
OUT="$HERE/build"
|
|
TARGET_DIR="${CARGO_TARGET_DIR:-$RS/target}"
|
|
SLICES="${WAI_SINK_SLICES:-macos ios ios-sim tvos tvos-sim}"
|
|
NIGHTLY="${WAI_SINK_NIGHTLY:-nightly-2026-10-17}"
|
|
FEATURES=(--no-default-features --features native_sink)
|
|
export MACOSX_DEPLOYMENT_TARGET=13.0 IPHONEOS_DEPLOYMENT_TARGET=16.0 TVOS_DEPLOYMENT_TARGET=16.0
|
|
|
|
build() { # <target> [nightly]
|
|
if [ "${2:-}" = nightly ]; then
|
|
cargo "+$NIGHTLY" build --release --locked "${FEATURES[@]}" --lib --manifest-path "$RS/Cargo.toml" \
|
|
--target "$1" -Zbuild-std=std,panic_abort
|
|
else
|
|
cargo build --release --locked "${FEATURES[@]}" --lib --manifest-path "$RS/Cargo.toml" --target "$1"
|
|
fi
|
|
}
|
|
lib() { echo "$TARGET_DIR/$1/release/libwai.a"; }
|
|
|
|
rm -rf "$OUT/WaiFFI.xcframework" "$OUT/headers" "$OUT/lib"
|
|
mkdir -p "$OUT/headers" "$OUT/lib"
|
|
cp "$RS/include/wai.h" "$OUT/headers/wai.h"
|
|
cat > "$OUT/headers/module.modulemap" <<'MAP'
|
|
module WaiFFI {
|
|
header "wai.h"
|
|
export *
|
|
}
|
|
MAP
|
|
args=()
|
|
for s in $SLICES; do
|
|
case "$s" in
|
|
macos)
|
|
build aarch64-apple-darwin; build x86_64-apple-darwin
|
|
mkdir -p "$OUT/lib/macos"
|
|
lipo -create "$(lib aarch64-apple-darwin)" "$(lib x86_64-apple-darwin)" -output "$OUT/lib/macos/libwai.a"
|
|
args+=(-library "$OUT/lib/macos/libwai.a" -headers "$OUT/headers") ;;
|
|
ios)
|
|
build aarch64-apple-ios
|
|
args+=(-library "$(lib aarch64-apple-ios)" -headers "$OUT/headers") ;;
|
|
ios-sim)
|
|
build aarch64-apple-ios-sim; build x86_64-apple-ios
|
|
mkdir -p "$OUT/lib/ios-sim"
|
|
lipo -create "$(lib aarch64-apple-ios-sim)" "$(lib x86_64-apple-ios)" -output "$OUT/lib/ios-sim/libwai.a"
|
|
args+=(-library "$OUT/lib/ios-sim/libwai.a" -headers "$OUT/headers") ;;
|
|
tvos)
|
|
build aarch64-apple-tvos nightly
|
|
args+=(-library "$(lib aarch64-apple-tvos)" -headers "$OUT/headers") ;;
|
|
tvos-sim)
|
|
build aarch64-apple-tvos-sim nightly
|
|
args+=(-library "$(lib aarch64-apple-tvos-sim)" -headers "$OUT/headers") ;;
|
|
*) echo "build-xcframework: unknown slice $s" >&2; exit 2 ;;
|
|
esac
|
|
done
|
|
xcodebuild -create-xcframework "${args[@]}" -output "$OUT/WaiFFI.xcframework"
|
|
# The corpus the tests read, staged into their bundle's resources so a test run on a device, where
|
|
# the repository is not, reads it too.
|
|
cp "$HERE/../live-conformance/native-sink/vectors.json" "$HERE/Tests/WaiSinkTests/Resources/vectors.json"
|
|
echo "wrote $OUT/WaiFFI.xcframework ($SLICES)"
|