# Maintainer: https://github.com/cathaysia
_realname=cppcoro
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=r390.a87e97f
pkgrel=2
pkgdesc=" A library of C++ coroutine abstractions for the coroutines TS (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clangarm64')
msys2_references=(
  'aur: cppcoro-git'
)
license=("MIT")
url="https://github.com/lewissbaker/cppcoro"
makedepends=('git')
_commit='a87e97f'
source=("${_realname}::git+https://github.com/lewissbaker/${_realname}.git#commit=${_commit}")
sha256sums=('SKIP')

pkgver() {
  cd "${srcdir}/${_realname}"
  printf "r%s.%s" "$(git rev-list --count "${_commit}")" "$(git rev-parse --short "${_commit}")"
}

build(){
  # replace all std::experimental with std
  find "${srcdir}/cppcoro/include/cppcoro/" -type f -exec sed -e 's/std::experimental/std/g' -e 's|experimental/||g' -i \{\} \+
}

package() {
  mkdir -p "${pkgdir}${MINGW_PREFIX}/"
  cp -r "${srcdir}/cppcoro/include/" "${pkgdir}${MINGW_PREFIX}/include/"
}
