# Maintainer: Jan Alexander Steffens (heftig) <heftig@archlinux.org>
# Contributor: Ionut Biru <ibiru@archlinux.org>

pkgbase=json-glib
pkgname=(json-glib json-glib-docs)
pkgver=1.6.6
pkgrel=2
pkgdesc="JSON library built on GLib"
url="https://wiki.gnome.org/Projects/JsonGlib"
arch=(x86_64)
license=(GPL)
depends=(glib2)
makedepends=(gobject-introspection git meson gi-docgen docbook-xsl)
options=(debug)
_commit=3cf2b53667a73376c852e08dcadd197a5f8325b9  # tags/1.6.6^0
source=("git+https://gitlab.gnome.org/GNOME/json-glib.git#commit=$_commit")
sha256sums=('SKIP')

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

prepare() {
  cd json-glib
}

build() {
  arch-meson json-glib build -D man=true
  meson compile -C build
}

check() {
  meson test -C build --print-errorlogs
}

package_json-glib() {
  depends+=(libg{lib,object,io}-2.0.so)
  provides+=(libjson-glib-1.0.so)

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

  mkdir -p doc/usr/share
  mv {"$pkgdir",doc}/usr/share/doc
  
  rm -r "$pkgdir"/usr/{lib,share}/installed-tests
}

package_json-glib-docs() {
  pkgdesc+=" (documentation)"
  depends=()

  mv doc/* "$pkgdir"
}

# vim:set sw=2 et:
