#!/bin/bash
echo "📦 Building Backend for Universal Binaries..."

# Ensure directories exist
mkdir -p backend/dist/amd64
mkdir -p backend/dist/arm64
mkdir -p backend/dist/universal

# Build for AMD64
# Build for AMD64
echo "⚙️  Building for AMD64..."
GOOS=darwin GOARCH=amd64 go build -ldflags="-s -w" -o backend/dist/amd64/backend backend/main.go

# Build for ARM64
echo "⚙️  Building for ARM64..."
GOOS=darwin GOARCH=arm64 go build -ldflags="-s -w" -o backend/dist/arm64/backend backend/main.go

# Create Universal Binary
echo "🔄 Creating Universal Binary..."
lipo -create -output backend/dist/universal/backend backend/dist/amd64/backend backend/dist/arm64/backend

echo "✅ Backend build complete: backend/dist/universal/backend"
