#!/usr/bin/env bash set -euo pipefail MODE="${1:-run}" ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" BUILD_DIR="$ROOT_DIR/build/dev" APP_BUNDLE="$BUILD_DIR/AVA2Dev.app" APP_NAME="AVA2Dev" case "$MODE" in run|--debug|--logs|--telemetry|--verify|--build-only) ;; *) echo "usage: $0 [--debug|--logs|--telemetry|--verify|--build-only]" >&2;exit 2;; esac # AVA2Dev is this project's development process; the stable Metin2 app is unrelated. pkill -x "$APP_NAME" >/dev/null 2>&1 || true cmake -S "$ROOT_DIR" -B "$BUILD_DIR" -DCMAKE_BUILD_TYPE=Debug cmake --build "$BUILD_DIR" -j 8 mkdir -p "$APP_BUNDLE/Contents/MacOS" "$APP_BUNDLE/Contents/Resources" cp "$BUILD_DIR/ava2_client" "$APP_BUNDLE/Contents/MacOS/$APP_NAME" cp "$BUILD_DIR/python27.zip" "$APP_BUNDLE/Contents/Resources/python27.zip" cp "$ROOT_DIR/runtime/login_view.py" "$APP_BUNDLE/Contents/Resources/login_view.py" mkdir -p "$APP_BUNDLE/Contents/Resources/root" cp "$ROOT_DIR"/upstream/python-root/*.py "$APP_BUNDLE/Contents/Resources/root/" cat > "$APP_BUNDLE/Contents/Info.plist" <<'PLIST' CFBundleExecutableAVA2Dev CFBundleIdentifierorg.ava2.client.dev CFBundleNameAVA2Dev CFBundlePackageTypeAPPL LSMinimumSystemVersion13.0 NSPrincipalClassNSApplication NSHighResolutionCapable PLIST # A local development bundle; SDL3 still resolves from the developer's SDK installation. case "$MODE" in --build-only) exit 0 ;; --debug) exec lldb -- "$APP_BUNDLE/Contents/MacOS/$APP_NAME" ;; run) /usr/bin/open -n "$APP_BUNDLE" ;; --verify) /usr/bin/open -n "$APP_BUNDLE";for i in 1 2 3 4 5;do if pgrep -x "$APP_NAME" >/dev/null;then exit 0;fi;sleep 1;done;exit 1 ;; --logs|--telemetry) /usr/bin/open -n "$APP_BUNDLE";exec /usr/bin/log stream --info --style compact --predicate 'process == "AVA2Dev"' ;; esac