# Maintainer: Alberto Fanjul Alonso <albfan@gnome.org>

_realname=granite
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=6.0.0
pkgrel=1
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64')
pkgdesc="git repository viewer for GTK+/GNOME (mingw-w64)"
depends=( "${MINGW_PACKAGE_PREFIX}-libgee"
          "${MINGW_PACKAGE_PREFIX}-gtk3")
makedepends=("${MINGW_PACKAGE_PREFIX}-meson"
             "${MINGW_PACKAGE_PREFIX}-ninja"
             "${MINGW_PACKAGE_PREFIX}-gcc"
             "${MINGW_PACKAGE_PREFIX}-pkg-config"
             "${MINGW_PACKAGE_PREFIX}-vala"
             "${MINGW_PACKAGE_PREFIX}-gobject-introspection"
             "${MINGW_PACKAGE_PREFIX}-itstool")
options=('strip')
license=("GPL3")
url="https://github.com/elementary/granite"
source=(https://github.com/elementary/${_realname}/archive/refs/tags/${pkgver}.tar.gz
        Build-on-windows.patch
       )
sha256sums=('c62d8d29e8bb59a5fa2d9006a9c13196aea9159410a7c86e3d51fa10d0f9dcc0'
            '857b3bede59016747b5042a6fc7f01857c96d6e0949bb0266e0f64c56a8645d9')

prepare() {
  cd "$srcdir/${_realname}-${pkgver}"
  patch -Np1 -i "${srcdir}/Build-on-windows.patch"
}

build() {
  [[ -d build-${MINGW_CHOST} ]] && rm -rf build-${MINGW_CHOST}
  mkdir -p build-${MINGW_CHOST}
  cd build-${MINGW_CHOST}

  MSYS2_ARG_CONV_EXCL="--prefix=" \
  meson \
    --prefix="${MINGW_PREFIX}" \
    --buildtype plain \
    -Dwerror=false \
    ../${_realname}-${pkgver}

  ninja
}

package() {
  cd "$srcdir/build-${MINGW_CHOST}"
  DESTDIR="${pkgdir}" ninja install

  install -Dm644 "${srcdir}/${_realname}-${pkgver}/COPYING" "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/COPYING"
}
