# Maintainer: funman300 <funman300@gmail.com>

pkgname=solitaire-quest
pkgver=0.1.0
pkgrel=1
pkgdesc='Cross-platform Klondike Solitaire with progression, achievements, and optional sync'
url='https://github.com/funman300/solitaire-quest'
license=('MIT')
arch=('x86_64')
makedepends=('cargo' 'rust')
depends=(
    'gcc-libs'
    'glibc'
    'alsa-lib'
    'libxkbcommon'
    'systemd-libs'   # libudev.so — required by Bevy input
)

# Build from the local workspace (two levels above this PKGBUILD).
_srcdir="$startdir/../.."
source=()
b2sums=()

prepare() {
    export RUSTUP_TOOLCHAIN=stable
    cd "$_srcdir"
    cargo fetch --locked --target "$(rustc -Vv | grep host | cut -d' ' -f2)"
}

build() {
    export RUSTUP_TOOLCHAIN=stable
    export CARGO_TARGET_DIR=target
    cd "$_srcdir"
    cargo build --frozen --release -p solitaire_app
}

check() {
    export RUSTUP_TOOLCHAIN=stable
    cd "$_srcdir"
    # Only test non-Bevy crates — Bevy integration tests require a GPU/display.
    cargo test --frozen -p solitaire_core -p solitaire_sync
}

package() {
    cd "$_srcdir"
    install -Dm0755 -t "$pkgdir/usr/bin/" "target/release/solitaire_app"
    install -Dm0644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
}
