# Packages the foundation shell from the git checkout that invoked makepkg.
# PAPERDOLL_PKGVER and REPO_ROOT are set by scripts/package/arch.sh.
pkgname=paperdoll-renderer
pkgver=0.1.0
pkgrel=1
pkgdesc='Foundation shell for the Paperdoll Renderer. Import and render are not included.'
arch=('x86_64')
url='https://git.timfalken.com/golden-age/paperdoll-renderer'
license=('MIT')
depends=('gcc-libs' 'glibc' 'libxcb' 'libx11' 'libxkbcommon' 'libglvnd')
makedepends=('cargo' 'pkgconf')
options=('!debug' '!lto')

pkgver() {
  printf '%s\n' "${PAPERDOLL_PKGVER:?set PAPERDOLL_PKGVER}"
}

build() {
  : "${REPO_ROOT:?set REPO_ROOT to the repository root}"
  export CARGO_HOME="${CARGO_HOME:-$REPO_ROOT/cargo-home}"
  cargo build --release --locked --manifest-path "$REPO_ROOT/Cargo.toml" --target-dir "$REPO_ROOT/target"
}

package() {
  : "${REPO_ROOT:?set REPO_ROOT to the repository root}"
  install -Dm755 "$REPO_ROOT/target/release/paperdoll-renderer" "$pkgdir/usr/bin/paperdoll-renderer"
  install -Dm644 "$REPO_ROOT/packaging/linux/paperdoll-renderer.desktop" \
    "$pkgdir/usr/share/applications/paperdoll-renderer.desktop"
  install -Dm644 "$REPO_ROOT/packaging/linux/icon-64.png" \
    "$pkgdir/usr/share/icons/hicolor/64x64/apps/paperdoll-renderer.png"
  install -Dm644 "$REPO_ROOT/LICENSE" "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
}
