# Maintainer: funman300 <funman300@gmail.com>
#
# AUR NOTE: This PKGBUILD is kept in the source repo for convenience during
# development. For AUR submission, move it to a separate repository and update
# the `source` array to point to the upstream git URL instead of a local path.
#
# To build locally:
#   cd packaging && makepkg -si
#
# To update for AUR, replace the source line with:
#   source=("$pkgname::git+https://git.aleshym.co/funman300/umutray.git#tag=v$pkgver")

pkgname=umutray
pkgver=0.1.0
pkgrel=4
pkgdesc='Tray-based Wine launcher manager for Linux via umu/Proton-GE'
arch=('x86_64')
url='https://git.aleshym.co/funman300/umutray'
license=('MIT')
depends=('umu-launcher')
makedepends=('rust' 'cargo')
optdepends=(
    'zenity: folder picker in setup wizard (GNOME/GTK)'
    'kdialog: folder picker in setup wizard (KDE)'
    'gamemode: per-game GameMode support'
    'mangohud: per-game MangoHud overlay'
    'gamescope: per-game Gamescope compositor'
)

# Build from the local repository. Change to the upstream URL for AUR.
_localrepo="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
source=("$pkgname::git+file://${_localrepo}")
sha256sums=('SKIP')

prepare() {
    cd "$pkgname"
    export RUSTUP_TOOLCHAIN=stable
    cargo fetch --locked --target "$(rustc -vV | sed -n 's/host: //p')"
}

build() {
    cd "$pkgname"
    export RUSTUP_TOOLCHAIN=stable
    export CARGO_TARGET_DIR=target
    cargo build --release --locked --offline
}

package() {
    cd "$pkgname"

    # Binary
    install -Dm755 target/release/umutray "$pkgdir/usr/bin/umutray"

    # App menu entry
    install -Dm644 umutray.desktop "$pkgdir/usr/share/applications/umutray.desktop"

    # License
    install -Dm644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
}
