# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=glade
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=3.40.0
pkgrel=8
pkgdesc="User interface builder for GTK+ and GNOME (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url="https://glade.gnome.org/"
license=("GPL" "LGPL")
depends=("${MINGW_PACKAGE_PREFIX}-adwaita-icon-theme"
         "${MINGW_PACKAGE_PREFIX}-cairo"
         "${MINGW_PACKAGE_PREFIX}-gdk-pixbuf2"
         "${MINGW_PACKAGE_PREFIX}-gettext-runtime"
         "${MINGW_PACKAGE_PREFIX}-glib-networking"
         "${MINGW_PACKAGE_PREFIX}-glib2"
         "${MINGW_PACKAGE_PREFIX}-gtk-update-icon-cache"
         "${MINGW_PACKAGE_PREFIX}-gtk3"
         "${MINGW_PACKAGE_PREFIX}-libxml2")
makedepends=("${MINGW_PACKAGE_PREFIX}-cc"
             "${MINGW_PACKAGE_PREFIX}-meson"
             "${MINGW_PACKAGE_PREFIX}-ninja"
             "${MINGW_PACKAGE_PREFIX}-pkgconf"
             "${MINGW_PACKAGE_PREFIX}-gettext-tools"
             "${MINGW_PACKAGE_PREFIX}-gtk-doc"
             "${MINGW_PACKAGE_PREFIX}-itstool"
             "${MINGW_PACKAGE_PREFIX}-gobject-introspection"
             "${MINGW_PACKAGE_PREFIX}-python-gobject"
             "${MINGW_PACKAGE_PREFIX}-gnome-common")
optdepends=("${MINGW_PACKAGE_PREFIX}-python: Python widgets support")
source=(https://download.gnome.org/sources/${_realname}/${pkgver%.*}/${_realname}-${pkgver}.tar.xz
        "0001-fix-stat-type.patch")
sha256sums=('31c9adaea849972ab9517b564e19ac19977ca97758b109edc3167008f53e3d9c'
            '363bd03bb65d018a7792a33eb930f034819a69242d6d0953f8a8efcb719efe2e')

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

  patch -Np1 -i "${srcdir}/0001-fix-stat-type.patch"
}

build() {
  mkdir -p "${srcdir}"/build-${MSYSTEM} && cd "${srcdir}"/build-${MSYSTEM}

  MSYS2_ARG_CONV_EXCL="--prefix=" \
  meson \
      --prefix="${MINGW_PREFIX}" \
      --buildtype plain \
      --auto-features=enabled \
       -Dgtk_doc=false \
       -Dgjs=disabled \
       -Dwebkit2gtk=disabled \
       -Dgladeui=true \
       -Dintrospection=true \
      ../${_realname}-${pkgver}

  meson compile
}

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

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