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

_realname=libvirt-glib
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=5.0.0
pkgrel=6
pkgdesc="libvirt GLib and GObject mapping library (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url="https://libvirt.org/"
msys2_repository_url='https://gitlab.com/libvirt/libvirt-glib/'
msys2_references=(
  'archlinux: libvirt-glib'
)
license=('spdx: LGPL-2.1-or-later')
depends=("${MINGW_PACKAGE_PREFIX}-glib2"
         "${MINGW_PACKAGE_PREFIX}-libxml2"
         "${MINGW_PACKAGE_PREFIX}-libvirt")
makedepends=("${MINGW_PACKAGE_PREFIX}-cc"
             "${MINGW_PACKAGE_PREFIX}-meson"
             "${MINGW_PACKAGE_PREFIX}-pkgconf"
             "${MINGW_PACKAGE_PREFIX}-gtk-doc"
             "${MINGW_PACKAGE_PREFIX}-vala"
             "${MINGW_PACKAGE_PREFIX}-gobject-introspection")
source=(https://libvirt.org/sources/glib/${_realname}-${pkgver}.tar.xz{,.asc})
sha256sums=('9bfec346382416a3575d87299bc641b2a464aa519fd9b1287e318aa43a2f3b8b'
            'SKIP')
validpgpkeys=('DAF3A6FDB26B62912D0E8E3FBE86EBB415104FDF') # Daniel P. Berrange <dan@berrange.com>

build() {
  MSYS2_ARG_CONV_EXCL="--prefix=" \
  ${MINGW_PREFIX}/bin/meson.exe setup \
    --prefix="${MINGW_PREFIX}" \
    --buildtype=plain \
    --wrap-mode=nodownload \
    --default-library=both \
    --auto-features=enabled \
    -Dgit_werror=disabled \
    "${_realname}-${pkgver}" \
    "build-${MSYSTEM}"

  ${MINGW_PREFIX}/bin/meson.exe compile -C "build-${MSYSTEM}"
}

package() {
  ${MINGW_PREFIX}/bin/meson.exe install -C "${srcdir}/build-${MSYSTEM}" --destdir "${pkgdir}"

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