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

_realname=eog
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=3.38.0
pkgrel=6
pkgdesc="Eye of GNOME graphics viewer program (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url="https://wiki.gnome.org/Apps/EyeOfGnome"
msys2_repository_url="https://gitlab.gnome.org/GNOME/eog"
msys2_references=(
  "cpe: cpe:/a:gnome:eog"
)
license=("spdx:GPL-2.0-or-later")
depends=("${MINGW_PACKAGE_PREFIX}-adwaita-icon-theme"
         "${MINGW_PACKAGE_PREFIX}-cairo"
         "${MINGW_PACKAGE_PREFIX}-gdk-pixbuf2"
         "${MINGW_PACKAGE_PREFIX}-gettext-runtime"
         "${MINGW_PACKAGE_PREFIX}-glib2"
         "${MINGW_PACKAGE_PREFIX}-gobject-introspection-runtime"
         "${MINGW_PACKAGE_PREFIX}-gsettings-desktop-schemas"
         "${MINGW_PACKAGE_PREFIX}-gtk-update-icon-cache"
         "${MINGW_PACKAGE_PREFIX}-gtk3"
         "${MINGW_PACKAGE_PREFIX}-libexif"
         "${MINGW_PACKAGE_PREFIX}-libjpeg-turbo"
         "${MINGW_PACKAGE_PREFIX}-libpeas"
         "${MINGW_PACKAGE_PREFIX}-librsvg"
         "${MINGW_PACKAGE_PREFIX}-libxml2"
         "${MINGW_PACKAGE_PREFIX}-shared-mime-info"
         "${MINGW_PACKAGE_PREFIX}-zlib")
optdepends=("${MINGW_PACKAGE_PREFIX}-libavif: Load .avif"
            "${MINGW_PACKAGE_PREFIX}-libheif: Load .heif, .heic, and .avif"
            "${MINGW_PACKAGE_PREFIX}-libjxl: Load .jxl"
            "${MINGW_PACKAGE_PREFIX}-webp-pixbuf-loader: Load .webp")
makedepends=("${MINGW_PACKAGE_PREFIX}-cc"
             "${MINGW_PACKAGE_PREFIX}-meson"
             "${MINGW_PACKAGE_PREFIX}-pkgconf"
             "${MINGW_PACKAGE_PREFIX}-ninja"
             "${MINGW_PACKAGE_PREFIX}-gettext-tools"
             "${MINGW_PACKAGE_PREFIX}-gobject-introspection"
             "${MINGW_PACKAGE_PREFIX}-gtk-doc"
             "${MINGW_PACKAGE_PREFIX}-yelp-tools")
source=(https://download.gnome.org/sources/${_realname}/${pkgver%.*}/${_realname}-$pkgver.tar.xz
        002-relocation-support.patch
        win.patch
        003-gui-app.patch
        004-symbol-vis.patch
        005-content-type-to-mime-type-conversion.patch
        https://gitlab.gnome.org/GNOME/eog/-/commit/07b60839da44988b3ad9e6ebc78bde4f3b0e622b.patch)
sha256sums=('e1a3a47c38688cd538deda627c0eff113d05c316b1dde6243150437259d2d963'
            'a7e897da94d7033fd2ad4d81129f7a60cd0f68bd8d887c079c79cef802d02a4d'
            'e04066d55e06a96faa9b828fbcdb6da6908bb118b7c58099a3404733d0cf70b3'
            '0569f7d5273c03d03095f455fa16974bf7a7cb83e2218190514530007bfc7b69'
            '3a7470893fe6681e907f03304be5263bd92cb1f14f30a521faf5a6e37a5f39c6'
            'a0f5b0dd7f690859c1ae53a102a1ca06db6d150d153dabf69fa1e75118ac30be'
            'ff65f7be25d8bc197e37ffa518c83a18e4d70eec4a6e2c552a9f34620d2abbd3')

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

  patch -p1 -i "${srcdir}"/002-relocation-support.patch
  patch -p1 -i "${srcdir}"/win.patch
  patch -p1 -i "${srcdir}"/003-gui-app.patch
  patch -p1 -i "${srcdir}"/004-symbol-vis.patch
  # https://gitlab.gnome.org/GNOME/eog/-/merge_requests/112
  patch -p1 -i "${srcdir}"/005-content-type-to-mime-type-conversion.patch
  patch -p1 -i "${srcdir}"/07b60839da44988b3ad9e6ebc78bde4f3b0e622b.patch
}

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

  MSYS2_ARG_CONV_EXCL="--prefix=" \
  ${MINGW_PREFIX}/bin/meson setup \
    --prefix=${MINGW_PREFIX} \
    --buildtype plain \
    -Dxmp=false \
    -Dcms=false \
    -Dlibportal=false \
    -Dintrospection=true \
    ../${_realname}-${pkgver}

  ${MINGW_PREFIX}/bin/meson compile
}

package() {
  cd "${srcdir}/build-${MSYSTEM}"

  DESTDIR="${pkgdir}" ${MINGW_PREFIX}/bin/meson install

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