#!/bin/bash # Build the Rust CalcPad engine for macOS. # # Produces a static library that the Swift Package Manager links against. # # Usage: # ./build-rust.sh # Build release (default) # ./build-rust.sh debug # Build debug # # Prerequisites: # - Rust toolchain with targets: aarch64-apple-darwin, x86_64-apple-darwin # - Install targets: rustup target add aarch64-apple-darwin x86_64-apple-darwin set -euo pipefail PROFILE="${1:-release}" ENGINE_DIR="$(cd "$(dirname "$0")/../calcpad-engine" && pwd)" OUTPUT_DIR="$ENGINE_DIR/target/$PROFILE" if [ "$PROFILE" = "debug" ]; then CARGO_FLAG="" else CARGO_FLAG="--release" fi echo "Building calcpad-engine ($PROFILE)..." # Build for the current architecture cd "$ENGINE_DIR" cargo build $CARGO_FLAG echo "" echo "Build complete!" echo "Static library: $OUTPUT_DIR/libcalcpad_engine.a" echo "" echo "To build and test the Swift package:" echo " cd calcpad-macos && swift test"