# Maintainer: Simon Zeni <simon@bl4ckb0ne.ca>
pkgname=level-zero
pkgver=1.21.9
pkgrel=0
pkgdesc="oneAPI Level Zero Specification Headers and Loader "
url="https://github.com/oneapi-src/level-zero"
arch="all"
license="MIT"
options="net" # Fetch gtest
makedepends="cmake samurai spdlog-dev python3"
subpackages="$pkgname-doc"
source="$pkgname-$pkgver.tar.gz::https://github.com/oneapi-src/level-zero/archive/refs/tags/v$pkgver.tar.gz
	xla-missing-include.patch"

build() {
	cmake -B build -G Ninja \
		-DCMAKE_BUILD_TYPE=None \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DSYSTEM_SPDLOG:BOOL=ON \
		-DBUILD_L0_LOADER_TESTS=ON \
		. -Wno-dev
	cmake --build build
}

check() {
	# Both tests are crashing
	ctest --test-dir build --output-on-failure \
		-E "tests_event_deadlock(_reset|)"
}

package() {
	DESTDIR="$pkgdir" cmake --install build

	install -Dm644 LICENSE "$pkgdir"/usr/share/licenses/$pkgname/LICENSE

	# Remove gtest and gmock from package
	rm -r $pkgdir/usr/include/gtest/
	rm -r $pkgdir/usr/include/gmock/
	rm -r $pkgdir/usr/lib/libgtest*
	rm -r $pkgdir/usr/lib/libgmock*
	rm -r $pkgdir/usr/lib/cmake
	rm -r $pkgdir/usr/lib/pkgconfig/gmock*
	rm -r $pkgdir/usr/lib/pkgconfig/gtest*
}

sha512sums="
4f92a8e193b841146f11709433f75bbda7f92ced6b5ce1f9947b395e05e6118ee8fe4805a5c8099a7e86371f12b9def84a83301f60e972a509087dba622cfde1  level-zero-1.21.9.tar.gz
1905e2058b6b59e625d81910fae1dfa9edef0182bd6536f8f2f85ab45e050a02b9d534994a08ae7fa4ce54e8b0ecefb1bb6f2807b400e9a7409f82b64ea33e80  xla-missing-include.patch
"
