Files
AVA2/scripts/build_and_run.sh
T

40 lines
2.1 KiB
Bash
Executable File

#!/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'
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0"><dict>
<key>CFBundleExecutable</key><string>AVA2Dev</string>
<key>CFBundleIdentifier</key><string>org.ava2.client.dev</string>
<key>CFBundleName</key><string>AVA2Dev</string>
<key>CFBundlePackageType</key><string>APPL</string>
<key>LSMinimumSystemVersion</key><string>13.0</string>
<key>NSPrincipalClass</key><string>NSApplication</string>
<key>NSHighResolutionCapable</key><true/>
</dict></plist>
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