#!/bin/bash

# Rust Build Script

SCRIPT_DIR="$(cd "$(dirname "$0")/.." && pwd)"
cd "$SCRIPT_DIR"

echo "=== Rust Build ==="
echo ""

# Kompilera Rust-programmet med cargo
cd src
cargo build --release

if [ $? -eq 0 ]; then
    echo "✓ Kompilering lyckades!"
    echo "Binär: target/release/print_hej"
    echo ""
    echo "För att köra:"
    echo "  ./bin/print_hej [decimaler]"
    
    # Kopiera till bin/ katalogen
    mkdir -p ../bin
    cp target/release/print_hej ../bin/
    echo "Binär kopierad till: bin/print_hej"
else
    echo "✗ Kompilering misslyckades!"
    exit 1
fi