mirror of
https://github.com/FluxaMedia/fluxa.git
synced 2026-08-09 00:17:35 +00:00
Enable rquickjs bindgen against the correct Apple SDK per target
rquickjs-sys has no prebuilt FFI bindings for iOS/tvOS targets, so bindgen needs the matching SDK sysroot (iphoneos/iphonesimulator/ appletvos/appletvsimulator) and clang target triple per cross-compiled target, or it silently uses the host's own headers and fails. Unverified here — no Xcode/macOS available in this environment; needs confirming on a real Mac before relying on it.
This commit is contained in:
parent
28501ff31b
commit
cfd7a4b32b
1 changed files with 47 additions and 2 deletions
|
|
@ -13,11 +13,56 @@ else
|
|||
cargo_profile="debug"
|
||||
fi
|
||||
|
||||
apple_sdk_for_rust_target() {
|
||||
case "$1" in
|
||||
aarch64-apple-ios) echo "iphoneos" ;;
|
||||
aarch64-apple-ios-sim | x86_64-apple-ios) echo "iphonesimulator" ;;
|
||||
aarch64-apple-tvos) echo "appletvos" ;;
|
||||
aarch64-apple-tvos-sim) echo "appletvsimulator" ;;
|
||||
*) echo "" ;;
|
||||
esac
|
||||
}
|
||||
|
||||
apple_clang_triple_for_rust_target() {
|
||||
case "$1" in
|
||||
aarch64-apple-ios) echo "arm64-apple-ios" ;;
|
||||
aarch64-apple-ios-sim) echo "arm64-apple-ios-simulator" ;;
|
||||
x86_64-apple-ios) echo "x86_64-apple-ios-simulator" ;;
|
||||
aarch64-apple-tvos) echo "arm64-apple-tvos" ;;
|
||||
aarch64-apple-tvos-sim) echo "arm64-apple-tvos-simulator" ;;
|
||||
*) echo "" ;;
|
||||
esac
|
||||
}
|
||||
|
||||
build_rust_core() {
|
||||
local rust_target=""
|
||||
local prev_was_target_flag=0
|
||||
for arg in "$@"; do
|
||||
if [[ "$prev_was_target_flag" == "1" ]]; then
|
||||
rust_target="$arg"
|
||||
break
|
||||
fi
|
||||
[[ "$arg" == "--target" ]] && prev_was_target_flag=1 || prev_was_target_flag=0
|
||||
done
|
||||
|
||||
local bindgen_env=()
|
||||
if [[ -n "$rust_target" ]]; then
|
||||
local sdk clang_triple sdk_path
|
||||
sdk="$(apple_sdk_for_rust_target "$rust_target")"
|
||||
clang_triple="$(apple_clang_triple_for_rust_target "$rust_target")"
|
||||
if [[ -n "$sdk" && -n "$clang_triple" ]]; then
|
||||
sdk_path="$(xcrun --sdk "$sdk" --show-sdk-path)"
|
||||
bindgen_env=(
|
||||
"LIBCLANG_PATH=$(xcode-select -p)/Toolchains/XcodeDefault.xctoolchain/usr/lib"
|
||||
"BINDGEN_EXTRA_CLANG_ARGS=--target=$clang_triple --sysroot=$sdk_path -isysroot $sdk_path"
|
||||
)
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ "$profile" == "Release" ]]; then
|
||||
cargo build --no-default-features --features ios "$@" --release
|
||||
env "${bindgen_env[@]}" cargo build --no-default-features --features ios "$@" --release
|
||||
else
|
||||
cargo build --no-default-features --features ios "$@"
|
||||
env "${bindgen_env[@]}" cargo build --no-default-features --features ios "$@"
|
||||
fi
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue