# Maintainer: Eli Schwartz <eschwartz@archlinux.org>
# Contributor: Alexandre Filgueira <alexfilgueira@cinnarch.com>
# Contributor: Ionut Biru <ibiru@archlinux.org>

pkgname=cjs
pkgver=5.0.0
pkgrel=1
pkgdesc="Javascript Bindings for Cinnamon"
arch=('x86_64')
url="https://github.com/linuxmint/${pkgname}"
license=('GPL')
depends=('gtk3' 'gobject-introspection-runtime' 'js78')
makedepends=('meson' 'samurai' 'gobject-introspection')
checkdepends=('xorg-server-xvfb')
source=("${pkgname}-${pkgver}.tar.gz::${url}/archive/${pkgver}.tar.gz"
        "${url}/commit/ac2737f524b4d667a7700b8ff077cd603ee21c59.patch")
sha512sums=('32524de39e17ffc3e70f83188aed5d6bcb39e9ac4d4a1aa980a1f45dfc7970c103868f270775fcd290de0a6c70035b61b04dc575c6bcc1375972aaa0abdd8e59'
            '3ef6c86fd6edacd913bdd116b74e4288df8ba1a3711b06c1ce59f42688940da8000ea923776ed9e3e64f35c9f24405bc28f0389db5ac183549d2e099e763e9a2')
b2sums=('b8d4e64472eefe15678fd2ebcd270161b779e5081b1f9fdff61c4410fdef601cff9bc948b423308059aa73de0b960d430711e8741c10511f758b41da8d96892f'
        '5b22e12006eacd92008f18807047bac053b9c01c9ce8cedd042006b6f9b358d95020a7270e4421238c280f6e7091c9467190a570e1b6ea6fccbb39eeaaa92b5e')

prepare() {
    cd "${srcdir}"/${pkgname}-${pkgver}

    # fix failing test checking for version number
    patch -p1 -i ../ac2737f524b4d667a7700b8ff077cd603ee21c59.patch
}

build() {
    mkdir -p "${srcdir}"/${pkgname}-${pkgver}/builddir
    cd "${srcdir}"/${pkgname}-${pkgver}/builddir

    meson --prefix=/usr \
          --libexecdir=/usr/lib \
          --buildtype=plain \
          -Dinstalled_tests=false \
          ..

    samu
}

check() {
    cd "${srcdir}"/${pkgname}-${pkgver}/builddir

    # Needs a display
    xvfb-run meson test --print-errorlogs
}

package() {
    cd "${srcdir}"/${pkgname}-${pkgver}/builddir

    DESTDIR="${pkgdir}" samu install
}
