# POWER Maintainer: Alexander Baldeck <alex.bldck@gmail.com>
# Maintainer: Fabian Bornschein <fabiscafe-at-mailbox-dot-org>
# Maintainer: Jan Alexander Steffens (heftig) <heftig@archlinux.org>

pkgbase=libpeas
pkgname=(
  libpeas
  libpeas-demos
  libpeas-docs
)
pkgver=1.36.0
pkgrel=5.1
pkgdesc="GObject Plugin System"
url="https://wiki.gnome.org/Projects/Libpeas"
arch=(x86_64 powerpc64le powerpc64 powerpc riscv64)
license=(LGPL)
depends=(
  gobject-introspection-runtime
  gtk3
)
makedepends=(
  gi-docgen
  git
  glib2-devel
  glade
  gobject-introspection
  lua51-lgi
  meson
  python-gobject
  python-setuptools
  vala
)
makedepends_powerpc=(luajit)
makedepends_powerpc64=(lua51)
makedepends_powerpc64le=(luajit)
makedepends_riscv64=(luajit)
makedepends_x86_64=(luajit)
checkdepends=(xorg-server-xvfb)
_commit=7f245fa5158204621c3469756a951b68a651c4fe  # tags/libpeas-1.36.0^0
source=("git+https://gitlab.gnome.org/GNOME/libpeas.git#commit=$_commit")
b2sums=('SKIP')

pkgver() {
  cd libpeas
  git describe --tags | sed 's/^libpeas-//;s/[^-]*-g/r&/;s/-/+/g'
}

prepare() {
  cd libpeas
}

build() {
  local meson_options=(
    -D gtk_doc=true
    -D vapi=true
  )

  arch-meson libpeas build "${meson_options[@]}"
  meson compile -C build
}

check() {
  xvfb-run -s '-nolisten local' \
    meson test -C build --print-errorlogs
}

_pick() {
  local p="$1" f d; shift
  for f; do
    d="$srcdir/$p/${f#$pkgdir/}"
    mkdir -p "$(dirname "$d")"
    mv "$f" "$d"
    rmdir -p --ignore-fail-on-non-empty "$(dirname "$f")"
  done
}

package_libpeas() {
  optdepends=(
    'lua51-lgi: Lua loader'
    'python-gobject: Python loader'
  )
  provides=(libpeas{,-gtk}-1.0.so)

  meson install -C build --destdir "$pkgdir"

  cd "$pkgdir"

  _pick demo usr/bin/peas-demo
  _pick demo usr/lib/peas-demo

  _pick docs usr/share/doc
}

package_libpeas-demos() {
  pkgdesc+=" (demo applications)"
  depends=(
    libpeas
    python-gobject
  )
  mv demo/* "$pkgdir"
}

package_libpeas-docs() {
  pkgdesc+=" (documentation)"
  depends=()
  mv docs/* "$pkgdir"
}

# vim:set sw=2 sts=-1 et:
