# Maintainer: Christoph Reiter <reiter.christoph@gmail.com>

_realname=oxipng
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=9.1.5
pkgrel=1
pkgdesc="A lossless PNG compression optimiser (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url="https://github.com/shssoichiro/oxipng"
msys2_repository_url="https://github.com/shssoichiro/oxipng"
msys2_references=(
  'purl: pkg:cargo/oxipng'
)
license=('spdx:MIT')
depends=("${MINGW_PACKAGE_PREFIX}-cc-libs")
makedepends=("${MINGW_PACKAGE_PREFIX}-rust"
             "${MINGW_PACKAGE_PREFIX}-cc")
source=("${_realname}-${pkgver}.tar.gz::https://github.com/shssoichiro/${_realname}/archive/v${pkgver}.tar.gz")
sha256sums=('8f99d5c67efa2a7550023bf610b90e65d421375c9ed7f37097f83ae5c05f85bd')

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

  # Generate man page
  cargo xtask mangen

  cargo build --release --locked
}

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

  install -Dm755 "target/release/${_realname}.exe" "${pkgdir}${MINGW_PREFIX}/bin/${_realname}.exe"
  install -Dm644 "target/xtask/mangen/manpages/${_realname}.1" "${pkgdir}${MINGW_PREFIX}/share/man/man1/${_realname}.1"
  install -Dm644 LICENSE "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/LICENSE"
}
