#!/bin/bash
# Build TSS library for Android using gomobile

set -e

echo "=== Building TSS Library for Android ==="

# Check if gomobile is installed
if ! command -v gomobile &> /dev/null; then
    echo "Installing gomobile..."
    go install golang.org/x/mobile/cmd/gomobile@latest
    gomobile init
fi

# Download dependencies
echo "Downloading Go dependencies..."
go mod tidy

# Build for Android
echo "Building Android AAR..."
gomobile bind -target=android -androidapi=26 -o ../app/libs/tsslib.aar .

echo "=== Build complete! ==="
echo "Output: ../app/libs/tsslib.aar"
