# Description: API and commands for processing SPIR-V modules
# URL: https://www.khronos.org/vulkan/
# Maintainer: Danny Rawlins, crux at romster dot me
# Depends on: cmake

name=spirv-tools
version=2021.2
## DEPS
_spirv_headers=07f259e68af3a540038fa32df522554e74f53ed5
release=1
source=(https://github.com/KhronosGroup/SPIRV-Tools/archive/v$version/SPIRV-Tools-v$version.tar.gz
	https://github.com/KhronosGroup/SPIRV-Headers/archive/$_spirv_headers/SPIRV-Headers-$_spirv_headers.tar.gz)

build() {
	mv SPIRV-Headers-$_spirv_headers SPIRV-Headers
	prt-get isinst ninja && PKGMK_SPIRV_TOOLS+=' -G Ninja'

	PKGMK_SPIRV_TOOLS+=" \
-S SPIRV-Tools-$version \
-D CMAKE_INSTALL_PREFIX=/usr \
-D CMAKE_INSTALL_LIBDIR=lib \
-D CMAKE_BUILD_TYPE=Release \
-D SPIRV_WERROR=OFF \
-D SPIRV-Headers_SOURCE_DIR=/usr \
-D PYTHON_EXECUTABLE=/usr/bin/python3 \
-DSPIRV-Headers_SOURCE_DIR="${SRC}"/SPIRV-Headers \
-Wno-dev"

	cmake -B build-static $PKGMK_SPIRV_TOOLS \
		-D CMAKE_C_FLAGS_RELEASE="${CFLAGS}" \
		-D CMAKE_CXX_FLAGS_RELEASE="${CXXFLAGS}" \
		-D BUILD_SHARED_LIBS=OFF
	cmake --build build-static

	cmake -B build-shared $PKGMK_SPIRV_TOOLS \
		-D CMAKE_C_FLAGS_RELEASE="${CFLAGS}" \
		-D CMAKE_CXX_FLAGS_RELEASE="${CXXFLAGS}" \
		-D BUILD_SHARED_LIBS=ON
	cmake --build build-shared

	DESTDIR=$PKG cmake --build build-static --target install
	DESTDIR=$PKG cmake --build build-shared --target install
}