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

_realname=gexiv2
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=0.12.2
pkgrel=1
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64')
pkgdesc="GObject-based wrapper around the Exiv2 library (mingw-w64)"
depends=("${MINGW_PACKAGE_PREFIX}-glib2"
         "${MINGW_PACKAGE_PREFIX}-exiv2")
makedepends=("${MINGW_PACKAGE_PREFIX}-meson"
             "${MINGW_PACKAGE_PREFIX}-ninja"
             "${MINGW_PACKAGE_PREFIX}-gcc"
             "${MINGW_PACKAGE_PREFIX}-vala"
             "${MINGW_PACKAGE_PREFIX}-python-gobject"
             "${MINGW_PACKAGE_PREFIX}-gobject-introspection"
             "${MINGW_PACKAGE_PREFIX}-gtk-doc")
options=('strip' 'staticlibs')
license=("LGPL 2.1")
url="https://www.gnome.org/"
source=(https://download.gnome.org/sources/${_realname}/${pkgver%.*}/${_realname}-${pkgver}.tar.xz)
sha256sums=('2322b552aca330eef79724a699c51a302345d5e074738578b398b7f2ff97944c')

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

}

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

  local _pyver=$(python3 -c "import sys; sys.stdout.write('.'.join(map(str, sys.version_info[:2])))")
  local _overrides="${MINGW_PREFIX}/lib/python${_pyver}/site-packages/gi/overrides"

  MSYS2_ARG_CONV_EXCL="--prefix=;-Dpython3_girdir=" \
  ${MINGW_PREFIX}/bin/meson \
    --prefix="${MINGW_PREFIX}" \
    --buildtype plain \
    -Dpython2_girdir=no \
    -Dpython3_girdir="${_overrides}" \
    -Dgtk_doc=true \
    ../${_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"
}
