#!/usr/bin/bash
# JOBoRun		: Jwm OpenBox Obarun RUNit
# Maintainer	: Joe Bo Run <joborun@disroot.org>
# PkgSource		: url="https://gittea.disroot.org/joborun-pkg/jobextra/$pkgname"
# Website		: https://pozol.eu
#-----------------------------------------| DESCRIPTION |---------------------------------------

pkgname=tbb
pkgver=2021.5.0
pkgrel=02
pkgdesc='High level abstract threading library'
arch=('x86_64')
url='https://www.threadingbuildingblocks.org/'
depends=('gcc-libs' 'hwloc')
makedepends=('cmake' 'inetutils' 'ninja' 'python' 'swig')
conflicts=('intel-tbb')
provides=("intel-tbb=$pkgver")
replaces=('intel-tbb')
source=(https://github.com/oneapi-src/oneTBB/archive/v$pkgver/$pkgname-$pkgver.tar.gz
        retry-pthread_create.patch::https://github.com/oneapi-src/oneTBB/pull/824.patch)

prepare() {
  # Patch for mold:
  patch -d oneTBB-$pkgver -p1 -i ../retry-pthread_create.patch
}

build() {
  cd oneTBB-$pkgver
  # TBB_STRICT is ON by default and turns on -Werror, but `-DTBB_STRICT=OFF` is currently broken:
  # https://github.com/oneapi-src/oneTBB/issues/847
  # Upstream doesn't support GCC 12 yet:
  # https://github.com/oneapi-src/oneTBB/issues/823#issuecomment-1128997690
  # So we turn off the problematic new warnings in GCC 12 manually.
  export CXXFLAGS="$CXXFLAGS -Wno-error=uninitialized -Wno-error=address"
  cmake -GNinja -DCMAKE_INSTALL_PREFIX=/usr -DTBB4PY_BUILD=ON .
  ninja all python_build
}

#check() {
#  cd oneTBB-$pkgver
#  ninja test
#}
# 
## 2 out 134 tests failed see check.log

package() {
  cd oneTBB-$pkgver
  DESTDIR="$pkgdir" ninja install
}

#---- license gpg-key sha256sums ----

license=('Apache')

sha256sums=(e5b57537c741400cf6134b428fc1689a649d7d38d9bb9c1b6d64f092ea28178a  # tbb-2021.5.0.tar.gz
	70b077d1cac26e35336a8217f9c56c1ce2c8885c6df6dfb9805aa8374dad9617) # retry-pthread_create.patch


 
 
