# Maintainer: Andrea Zagli <andrea.zagli.free@gmail.com>

_realname=uhttpmock
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=0.11.0
pkgrel=2
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
pkgdesc="uhttpmock is a HTTP web service mocking project for projects which use libsoup (mingw-w64)"
depends=("${MINGW_PACKAGE_PREFIX}-glib2"
         "${MINGW_PACKAGE_PREFIX}-libsoup3")
makedepends=("${MINGW_PACKAGE_PREFIX}-cc"
            "${MINGW_PACKAGE_PREFIX}-gobject-introspection"
            "${MINGW_PACKAGE_PREFIX}-vala"
            "${MINGW_PACKAGE_PREFIX}-meson"
            "${MINGW_PACKAGE_PREFIX}-ninja")
license=("spdx:LGPL-2.1-or-later")
url="https://gitlab.freedesktop.org/pwithnall/uhttpmock"
source=(https://tecnocode.co.uk/downloads/${_realname}/${_realname}-${pkgver}.tar.xz
        0001-wsock.patch)
sha256sums=('feedc01a2ade9f0dcd61e73838ad53733d3cf68b7d51379acc00c894ea7884bf'
            '61a3563903d979a93514e09582400ed0647e3029a0632d5c6fbbd0f0589ba809')

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

  patch -p1 -i "${srcdir}"/0001-wsock.patch
}

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

  MSYS2_ARG_CONV_EXCL="--prefix=" \
  meson setup \
    --prefix="${MINGW_PREFIX}" \
    --wrap-mode=nodownload \
    --default-library=both \
    --buildtype=plain \
    -Dgtk_doc=false \
    "../${_realname}-${pkgver}"

  meson compile
}

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

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