Repository Public
1#!/usr/bin/env bash2# ORIX Sonata3# File: Scripts/build-rust.sh4# Description: Builds the Rust static library (arm64) and wraps it with its C header as Packages/SonataBridge/Frameworks/SonataFFI.xcframework. Usage: build-rust.sh [debug|release]5#6# Author: Simon-Pierre Boucher7# Contact: contact@spboucher.ai8set -euo pipefail9cd "$(dirname "$0")/.."10MODE="${1:-release}"11if [[ "$MODE" == "release" ]]; then PROFILE=release; DIR=release; else PROFILE=dev; DIR=debug; fi12export MACOSX_DEPLOYMENT_TARGET=15.013cargo build -p sonata-ffi -p sonata-cli -p sonata-lsp --profile "$PROFILE" --target aarch64-apple-darwin14LIB="target/aarch64-apple-darwin/$DIR/libsonata_ffi.a"15[[ -f "$LIB" ]] || { echo "ERROR: $LIB was not produced." >&2; exit 1; }16OUT="Packages/SonataBridge/Frameworks/SonataFFI.xcframework"17STAGE="build/ffi-headers"18rm -rf "$OUT" "$STAGE" && mkdir -p "$STAGE" "$(dirname "$OUT")"19cp crates/sonata-ffi/include/sonata.h "$STAGE/"20cat > "$STAGE/module.modulemap" <<'MAP'21module SonataFFI {22 header "sonata.h"23 export *24}25MAP26xcodebuild -create-xcframework -library "$LIB" -headers "$STAGE" -output "$OUT" >/dev/null27echo "built $OUT ($MODE, $(du -h "$LIB" | cut -f1) static library)"28