YrXtals/scripts/macos/debug.sh

45 lines
1.1 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
cd "$ROOT"
case "$(uname -s)" in
Darwin) ;;
*) echo "wrong platform: $(uname -s), use cargo xtask debug" >&2; exit 1;;
esac
BUILD="$ROOT/build"
APP="$BUILD/bin/Yr Xtals.app"
CONTENTS="$APP/Contents"
MACOS="$CONTENTS/MacOS"
RESOURCES="$CONTENTS/Resources"
export MACOSX_DEPLOYMENT_TARGET=14.0
export RUST_BACKTRACE=1
echo "Building Rust binary (debug)..."
cargo build --bin yr_crystals
BIN="/tmp/yr_crystals-target/debug/yr_crystals"
if [ ! -f "$BIN" ]; then
echo "ERROR: yr_crystals binary not found at $BIN" >&2
exit 1
fi
mkdir -p "$MACOS" "$RESOURCES"
cp "$ROOT/macos/Info.plist" "$CONTENTS/Info.plist"
cp "$BIN" "$MACOS/yr_crystals"
[ -f "$BUILD/AppIcon.icns" ] && cp "$BUILD/AppIcon.icns" "$RESOURCES/AppIcon.icns"
codesign --force --sign - "$APP"
pkill -f "Yr Xtals.app/Contents/MacOS/yr_crystals" 2>/dev/null || true
sleep 0.3
echo
echo "Launching $MACOS/yr_crystals. Rust panics will print below."
echo "(Ctrl+C to exit, or quit Yr Xtals normally.)"
echo "----------------------------------------------------------"
exec "$MACOS/yr_crystals"