pkgname=tauclock-git
pkgver=0.1.0.r0.g0000000
pkgrel=1
pkgdesc="Keyboard-driven clock, alarm, timer, and stopwatch desktop app built with Tauri"
arch=('x86_64')
url="https://git.rumginger.org/kamat/tauclock.git"
license=('MIT')
depends=(
  'gtk3'
  'webkit2gtk-4.1'
)
makedepends=(
  'cargo'
  'git'
  'rust'
)
source=("git+${url}")
sha256sums=('SKIP')

pkgver() {
  cd "${srcdir}/tauclock/src-tauri"
  local version
  version="$(grep -m1 '^version = ' Cargo.toml | cut -d'"' -f2)"
  printf '%s.r%s.g%s' "${version}" \
    "$(git rev-list --count HEAD)" \
    "$(git rev-parse --short HEAD)"
}

build() {
  cd "${srcdir}/tauclock/src-tauri"
  export CARGO_TARGET_DIR="${srcdir}/target"
  cargo build --release --locked
}

package() {
  cd "${srcdir}/tauclock"

  install -Dm755 "${srcdir}/target/release/tauclock" \
    "${pkgdir}/usr/bin/tauclock"
  install -Dm644 "tauclock.desktop" \
    "${pkgdir}/usr/share/applications/tauclock.desktop"
  install -Dm644 "src-tauri/icons/128x128.png" \
    "${pkgdir}/usr/share/icons/hicolor/128x128/apps/tauclock.png"
  install -Dm644 "LICENSE" \
    "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
}
