# Maintainer: Dominic Sisneros <dsisnero@gmail.com>

_realname=mruby
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=2.1.2
pkgrel=1
pkgdesc="mruby is the lightweight implementation of the Ruby language (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64')
url="https://github.com/mruby"
license=('MIT')
makedepends=("${MINGW_PACKAGE_PREFIX}-ruby"
             "bison")
source=(${_realname}-${pkgver}.zip::"https://github.com/${_realname}/${_realname}/archive/${pkgver}.zip")
sha256sums=('15ac56203823f0c8e60100062d73f7c96a16b855b195f00f0f0e03716cd6768c')

build() {
  [[ -d ${srcdir}/build-${MINGW_CHOST} ]] && rm -rf ${srcdir}/build-${MINGW_CHOST}
  cp -rf "${srcdir}/${_realname}-${pkgver}" ${srcdir}/build-${MINGW_CHOST}
  cd ${srcdir}/build-${MINGW_CHOST}

  ./minirake
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  install -d "${pkgdir}${MINGW_PREFIX}"/bin
  cp build/host-debug/bin/* "${pkgdir}${MINGW_PREFIX}"/bin/ || return 1
  cp build/host/bin/* "${pkgdir}${MINGW_PREFIX}"/bin/ || return 1

  install -d "${pkgdir}${MINGW_PREFIX}"/lib
  cp build/host/lib/*.a "${pkgdir}${MINGW_PREFIX}"/lib/

  install -d "${pkgdir}${MINGW_PREFIX}"/include
  cp -r include/* "${pkgdir}${MINGW_PREFIX}"/include/
}
