# Maintainer: Ray Donnelly <mingw.android@gmail.com>
# Based on Arch Linux package maintained by : Balló György <ballogyor+arch at gmail dot com>

_realname=d-feet
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=0.3.15
pkgrel=5
pkgdesc="D-Bus debugger for GNOME (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64')
url="https://wiki.gnome.org/Apps/DFeet"
license=('GPL')
depends=("${MINGW_PACKAGE_PREFIX}-gtk3"
         "${MINGW_PACKAGE_PREFIX}-python3-gobject"
         "${MINGW_PACKAGE_PREFIX}-hicolor-icon-theme")
makedepends=("${MINGW_PACKAGE_PREFIX}-python3-setuptools"
             "${MINGW_PACKAGE_PREFIX}-gobject-introspection"
             "${MINGW_PACKAGE_PREFIX}-meson"
             "${MINGW_PACKAGE_PREFIX}-ninja"
             "${MINGW_PACKAGE_PREFIX}-gtk-doc"
             "${MINGW_PACKAGE_PREFIX}-itstool")
source=(https://download.gnome.org/sources/${_realname}/${pkgver%.*}/${_realname}-${pkgver}.tar.xz
        001-make-reloc.patch)
sha256sums=('1fff149ad01ccbd93c927f5733346a9122324b9d367da3adbf4f1a52e47dfdb1'
            '5f4002b12ddf5c077976f4f20d1664070e9b36c9af0c28b0b89c994e29c59803')

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

  patch -Np1 -i "${srcdir}"/001-make-reloc.patch
}

build() {
  [[ -d "${srcdir}/build-${CARCH}" ]] && rm -rf ${srcdir}/build-${CARCH}
  mkdir -p ${srcdir}/build-${CARCH} && cd ${srcdir}/build-${CARCH}

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

  ${MINGW_PREFIX}/bin/ninja
}

package() {
  cd "${srcdir}/build-${CARCH}"
  DESTDIR="${pkgdir}" ${MINGW_PREFIX}/bin/ninja install
  install -Dm0644 "${srcdir}/${_realname}-${pkgver}"/COPYING ${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/COPYING
}
