# Arch package of Nacre, built from the last commit of this checkout. Use ../../install.sh, or makepkg -si here.
pkgname=nacre
pkgver=0.4.0
pkgrel=1
pkgdesc="A web browser built on WebKitGTK"
arch=(x86_64)
url="https://archlinux.tail7c4f5e.ts.net/git/astar76/Nacre"
license=(MPL-2.0)
depends=(webkitgtk-6.0 gtk4 gst-plugins-base gst-plugins-good gst-plugins-bad gst-libav dbus pam glibc libgcc libepoxy libsoup3 gstreamer hicolor-icon-theme xdg-utils)
makedepends=(cargo git pkgconf)
optdepends=('libnotify: desktop notifications'
            'xdg-desktop-portal: file pickers'
            'gnome-keyring: keeps the cookie key'
            'gst-plugin-pipewire: sound through PipeWire'
            'cava: music bars'
            'tor: Tor windows')
options=(!lto !debug)
# install.sh sets NACRE_SRC because it runs a copy of this file (makepkg rewrites pkgver in place).
source=("nacre::git+file://${NACRE_SRC:-$(git -C "${startdir:-.}" rev-parse --show-toplevel)}")
sha256sums=(SKIP)

pkgver() {
  cd nacre
  printf '%s.r%s.g%s' "$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | head -1)" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
}

build() {
  cd nacre
  export CARGO_TARGET_DIR="$srcdir/target"
  nice cargo build --release --locked -j "${NACRE_JOBS:-2}"
}

package() {
  cd nacre
  install -Dm755 "$srcdir/target/release/nacre" "$pkgdir/usr/bin/nacre"
  install -Dm755 "$srcdir/target/release/libnacre_webext.so" "$pkgdir/usr/lib/nacre/libnacre_webext.so"
  install -Dm644 -t "$pkgdir/usr/share/nacre/filters" assets/filters/*.txt
  install -Dm644 assets/dev.nacre.Nacre.desktop "$pkgdir/usr/share/applications/dev.nacre.Nacre.desktop"
  install -Dm644 assets/dev.nacre.Nacre.svg "$pkgdir/usr/share/icons/hicolor/scalable/apps/dev.nacre.Nacre.svg"
}
