# Maintainer: joy <chang.li@westberrytech.com>

_realname=wb32-dfu-updater
pkgbase=mingw-w64-${_realname}
pkgname=${MINGW_PACKAGE_PREFIX}-${_realname}
pkgver=1.0.0
pkgrel=1
pkgdesc='Device firmware upgrade utilities (mingw-w64)'
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
license=('spdx:Apache-2.0')
groups=("${MINGW_PACKAGE_PREFIX}-eda")
url='https://github.com/WestberryTech/wb32-dfu-updater/'
depends=("${MINGW_PACKAGE_PREFIX}-libusb")
makedepends=("${MINGW_PACKAGE_PREFIX}-cc"
             "${MINGW_PACKAGE_PREFIX}-cmake"
             "${MINGW_PACKAGE_PREFIX}-ninja")
source=("https://github.com/WestberryTech/wb32-dfu-updater/archive/${pkgver}/${_realname}-${pkgver}.tar.gz")
sha256sums=('2b1c5b5627723067168af9740cb25c5c179634e133e4ced06028462096de5699')

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

    MSYS2_ARG_CONV_EXCL="-DCMAKE_INSTALL_PREFIX=" \
    ${MINGW_PREFIX}/bin/cmake.exe \
      -G"Ninja" \
      -DCMAKE_INSTALL_PREFIX=${MINGW_PREFIX} \
      -DCMAKE_BUILD_TYPE=Release \
      ../${_realname}-${pkgver}

    ${MINGW_PREFIX}/bin/cmake.exe --build ./
}

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

    DESTDIR="${pkgdir}" ${MINGW_PREFIX}/bin/cmake.exe --install ./
}
