#!/bin/sh set -eu cd "$(dirname "$0")/.." platform="${1:-macos}" case "$platform" in macos) mkdir -p target/debug sh scripts/go-local.sh build -mod=readonly -trimpath -buildmode=c-shared -o "$PWD/target/debug/libmeshport_proxy.dylib" ./cmd/meshport-singbox-ffi ;; android) sdk="${ANDROID_SDK_ROOT:-$HOME/Library/Android/sdk}" ndk="$sdk/ndk/28.2.13676358/toolchains/llvm/prebuilt/darwin-x86_64/bin" mkdir -p target/singbox/android-arm64 export GOOS=android GOARCH=arm64 CGO_ENABLED=1 export CC="$ndk/aarch64-linux-android26-clang" export CGO_LDFLAGS='-Wl,-z,max-page-size=16384' sh scripts/go-local.sh build -mod=readonly -trimpath -buildmode=c-shared -o "$PWD/target/singbox/android-arm64/libmeshport_proxy.so" ./cmd/meshport-singbox-ffi ;; *) printf '%s\n' 'usage: build-singbox-library.sh [macos|android]' >&2; exit 2 ;; esac