#!/bin/zsh # Wraps a built mt_native_render into a double-clickable Metin2.app with the branding icon: # scripts/package_mac_app.sh [BUILD_DIR=build/release] [CLIENT_DIR=/Client] [OUT=BUILD_DIR/Metin2.app] # The bundle is for this machine: the executable still links Homebrew's SDL3 / Vulkan loader / MoltenVK, and # the launcher runs the live client from CLIENT_DIR (an absolute path baked in; MT_CLIENT_DIR overrides it # at launch). The shaders and python27.zip go to Contents/Resources, which SDL_GetBasePath returns in a bundle. set -euo pipefail repo=${0:A:h:h} build=${1:-$repo/build/release} client=${2:-$repo/Client} out=${3:-$build/Metin2.app} bin=$build/src/host/mt_native_render [[ -x $bin ]] || { echo "missing $bin (build the mt_native_render target first)" >&2; exit 1; } client=${client:A} version=$(git -C $repo describe --always --dirty 2>/dev/null || echo dev) rm -rf $out mkdir -p $out/Contents/MacOS $out/Contents/Resources cp $bin $out/Contents/MacOS/ cp $build/src/host/native.vert.spv $build/src/host/native.frag.spv $build/src/host/python27.zip $out/Contents/Resources/ cp $repo/branding/icon/macos/AppIcon.icns $out/Contents/Resources/ cat > $out/Contents/MacOS/Metin2 < $out/Contents/Info.plist < CFBundleNameMetin2 CFBundleDisplayNameMetin2 CFBundleIdentifierorg.metin2port.client CFBundleExecutableMetin2 CFBundleIconFileAppIcon CFBundlePackageTypeAPPL CFBundleShortVersionString0.1 CFBundleVersion$version LSMinimumSystemVersion12.0 LSApplicationCategoryTypepublic.app-category.role-playing-games NSHighResolutionCapable EOF # Ad-hoc signature so Gatekeeper on Apple silicon runs the copied binary. codesign --force --deep --sign - $out >/dev/null 2>&1 || true echo $out