52 lines
1.5 KiB
Bash
Executable File
52 lines
1.5 KiB
Bash
Executable File
#!/bin/bash
|
|
# Build Archipelago backend binary for Alpine Linux
|
|
|
|
set -e
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
|
|
BACKEND_DIR="$PROJECT_ROOT/core/archipelago"
|
|
OUTPUT_DIR="$SCRIPT_DIR/../build/backend"
|
|
|
|
echo "🔨 Building Archipelago backend..."
|
|
echo " Source: $BACKEND_DIR"
|
|
echo " Output: $OUTPUT_DIR"
|
|
echo ""
|
|
|
|
# Check if Rust is installed
|
|
if ! command -v rustc >/dev/null 2>&1; then
|
|
echo "❌ Rust not found. Installing..."
|
|
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
|
|
source "$HOME/.cargo/env"
|
|
fi
|
|
|
|
# Create output directory
|
|
mkdir -p "$OUTPUT_DIR"
|
|
|
|
# Build backend
|
|
cd "$BACKEND_DIR"
|
|
echo "📦 Compiling backend..."
|
|
cargo build --release --target x86_64-unknown-linux-musl || {
|
|
# Try without musl target if cross-compilation not set up
|
|
echo "⚠️ Musl target not available, building for host..."
|
|
cargo build --release
|
|
}
|
|
|
|
# Copy binary
|
|
if [ -f "target/x86_64-unknown-linux-musl/release/archipelago" ]; then
|
|
cp "target/x86_64-unknown-linux-musl/release/archipelago" "$OUTPUT_DIR/archipelago"
|
|
elif [ -f "target/release/archipelago" ]; then
|
|
cp "target/release/archipelago" "$OUTPUT_DIR/archipelago"
|
|
else
|
|
echo "❌ Binary not found after build"
|
|
exit 1
|
|
fi
|
|
|
|
# Strip binary for smaller size
|
|
if command -v strip >/dev/null 2>&1; then
|
|
strip "$OUTPUT_DIR/archipelago"
|
|
fi
|
|
|
|
echo "✅ Backend built: $OUTPUT_DIR/archipelago"
|
|
ls -lh "$OUTPUT_DIR/archipelago"
|