pkgname=spirv-tools
pkgver=1.4.328.0
pkgdesc="API and commands for processing SPIR-V modules"
homepage="https://www.khronos.org/spirv/"
arch=(x86_64)
license=(Apache-2.0)
depends=(
  gcc-libs
  glibc
  sh
)
makedepends=(
  cmake
  ninja
  python
  spirv-headers
)
sources=("${pkgname}-${pkgver}.tar.gz")
urls=("https://github.com/KhronosGroup/SPIRV-Tools/archive/vulkan-sdk-${pkgver}.tar.gz")
md5sums=("fb85e921e1b4aa29491f10a83c72f7cb")

src_prepare() {
  tar -xf ${distdir}/${sources[0]} --strip-components=1
}

src_build() {
  local cmake_options=(
    -D BUILD_SHARED_LIBS=ON
    -D CMAKE_BUILD_TYPE=Release
    -D CMAKE_INSTALL_PREFIX=/usr
    -D CMAKE_INSTALL_SYSCONFDIR=/etc
    -D CMAKE_SKIP_INSTALL_RPATH=ON
    -D SPIRV-Headers_SOURCE_DIR=/usr
    -D SPIRV_TOOLS_BUILD_STATIC=OFF
    -D SPIRV_WERROR=OFF
  )

  cmake -B build -G Ninja "${cmake_options[@]}"
  cmake --build build
}

src_check() {
  ctest --test-dir build --output-on-failure --stop-on-failure
}

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

# vim:ft=sh syn=sh et sw=2:
