# Maintainer: yumetodo <yume-wikijp@live.jp>

_realname=tl-expected
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=1.0.0
pkgrel=2
pkgdesc="C++11/14/17 std::expected with functional-style extensions (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32')
url='https://github.com/TartanLlama/expected'
license=('custom:CC0')
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc"
             "${MINGW_PACKAGE_PREFIX}-cmake"
             "${MINGW_PACKAGE_PREFIX}-ninja")
source=("expected-v1.0.0.tar.gz::https://github.com/TartanLlama/expected/archive/v1.0.0.tar.gz")
sha256sums=("8f5124085a124113e75e3890b4e923e3a4de5b26a973b891b3deb40e19c03cee")

prepare() {
  mkdir "expected-$pkgver/build"
}

build() {
  cd "expected-$pkgver/build"
  MSYS2_ARG_CONV_EXCL="-DCMAKE_INSTALL_PREFIX=" \
  ${MINGW_PREFIX}/bin/cmake \
    -G"Ninja" \
    -DCMAKE_CXX_STANDARD=17 \
    -DCMAKE_INSTALL_PREFIX=${MINGW_PREFIX} \
    ..

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

check() {
  cd "expected-$pkgver/build"
  ./tests
}

package() {
  cd "expected-$pkgver/build"

  DESTDIR="${pkgdir}" ${MINGW_PREFIX}/bin/cmake --build ./ --target install
  cd ..
  install -Dm644 COPYING "${pkgdir}${MINGW_PREFIX}/usr/share/licenses/${_realname}/LICENSE"
}
