# Maintainer: James HoneyBadger <james@amiga-fan.net>
# Tessera Grid — native cellular-automaton simulator (Rust/egui).
#
# Builds from the versioned GitHub source tag using the checked-in Cargo.lock.
# The AUR submission workflow is documented in docs/packaging.md; do not
# publish without maintainer authorization.

pkgname=tessera-grid
pkgver=6.5.1
pkgrel=1
pkgdesc="Native cellular-automaton simulator (Rust/egui)"
arch=('x86_64')
url="https://github.com/James-HoneyBadger/TesseraGrid"
license=('MIT')
depends=('gcc-libs' 'libx11' 'libxkbcommon' 'wayland' 'libgl')
makedepends=('cargo')
options=(!lto)
source=("$pkgname-$pkgver.tar.gz::https://github.com/James-HoneyBadger/TesseraGrid/archive/refs/tags/v$pkgver.tar.gz")
# Fill in with `makepkg -g` once the v6.5.1 tag exists and the archive is
# stable. SKIP is not acceptable for a published AUR package.
sha256sums=('SKIP')

prepare() {
  cd "TesseraGrid-$pkgver"
  # cargo uses the repository's rust-toolchain.toml (pinned to the MSRV).
  # --locked guarantees the dependency set comes from Cargo.lock, so the build
  # performs no uncontrolled resolution beyond what the lockfile pins.
  cargo fetch --locked --manifest-path tessera-grid-rs/Cargo.toml
}

build() {
  cd "TesseraGrid-$pkgver/tessera-grid-rs"
  cargo build --release --locked
}

package() {
  cd "TesseraGrid-$pkgver"
  install -Dm755 tessera-grid-rs/target/release/tessera "$pkgdir/usr/bin/tessera"
  install -Dm644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
  install -Dm644 packaging/arch/tessera-grid.desktop \
    "$pkgdir/usr/share/applications/tessera-grid.desktop"
  install -Dm644 packaging/arch/tessera-grid.svg \
    "$pkgdir/usr/share/icons/hicolor/scalable/apps/tessera-grid.svg"
  install -Dm644 packaging/arch/tessera-grid.appdata.xml \
    "$pkgdir/usr/share/metainfo/tessera-grid.appdata.xml"
}
