# Packager = Tuxcore <dev@tuxcore.org> 
pkgname=onetbb
pkgver=2022.0.0
pkgrel=1
pkgdesc='High level abstract threading library (oneAPI Threading Building Blocks)'
arch=('x86_64')
url='https://oneapi-src.github.io/oneTBB/'
license=('Apache')
depends=('gcc-libs' 'hwloc')
makedepends=('cmake' 'ninja' 'python' 'swig' 'python-setuptools')
conflicts=('intel-tbb' 'tbb')
provides=("intel-tbb=$pkgver" "tbb=$pkgver")
replaces=('intel-tbb' 'tbb')
source=(https://github.com/oneapi-src/oneTBB/archive/v$pkgver/$pkgname-$pkgver.tar.gz)
sha512sums=('c87b84964b2c323f61895a532968dfa6413a774c177cffbf6e798a07e74e8da5d449144875771df0a1b02657eeb2a7ae4d41c6c432dbf7ea50e3d5a9ea9f8cd3')

build() {
  cmake -B build -S oneTBB-$pkgver -GNinja \
          -DCMAKE_INSTALL_PREFIX=/usr \
          -DTBB_STRICT=OFF \
          -DTBB4PY_BUILD=ON \
          -DCMAKE_BUILD_TYPE=None
  cmake --build build
}

check() {
  cd build
  ctest -E test_partitioner # hangs on build server
}

package() {
  DESTDIR="$pkgdir" cmake --install build
  rm -r "$pkgdir"/usr/lib/python*
  cd oneTBB-$pkgver/python
  TBBROOT="$pkgdir"/usr python setup.py install --root="$pkgdir"
}
