# Contributor: Mehdi Chinoune <mehdi.chinoune@hotmail.com>

_realname=Vulkan-Utility-Libraries
pkgbase=mingw-w64-vulkan-utility-libraries
pkgname=("${MINGW_PACKAGE_PREFIX}-vulkan-utility-libraries")
pkgver=1.4.328.1
pkgrel=1
pkgdesc='Libraries for Vulkan developers (mingw-w64)'
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url="https://www.khronos.org/vulkan/"
msys2_repository_url="https://github.com/KhronosGroup/Vulkan-Utility-Libraries"
msys2_references=(
  'anitya: 370173'
  'archlinux: vulkan-utility-libraries'
  'cpe: cpe:2.3:a:khronos:vulkan'
  'gentoo: dev-util/vulkan-utility-libraries'
)
license=('spdx:Apache-2.0')
groups=("${MINGW_PACKAGE_PREFIX}-vulkan-devel")
makedepends=("${MINGW_PACKAGE_PREFIX}-cc"
             "${MINGW_PACKAGE_PREFIX}-cmake"
             "${MINGW_PACKAGE_PREFIX}-ninja"
             "${MINGW_PACKAGE_PREFIX}-vulkan-headers")
conflicts=("${MINGW_PACKAGE_PREFIX}-vulkan-validation-layers<1.3.268")
source=("https://github.com/KhronosGroup/${_realname}/archive/vulkan-sdk-${pkgver}/${_realname}-${pkgver}.tar.gz")
sha256sums=('953ef4c2547b1611f90102f531f362bcfd6c76751eba2ae8c0f23b38947ef48d')

build() {
  mkdir -p "${srcdir}"/build-${MSYSTEM} && cd "${srcdir}"/build-${MSYSTEM}

  declare -a extra_config
  if check_option "debug" "n"; then
    extra_config+=("-DCMAKE_BUILD_TYPE=Release")
  else
    extra_config+=("-DCMAKE_BUILD_TYPE=Debug")
  fi

  MSYS2_ARG_CONV_EXCL="-DCMAKE_INSTALL_PREFIX=" \
  ${MINGW_PREFIX}/bin/cmake.exe \
    -G "Ninja" \
    "${extra_config[@]}" \
    -DCMAKE_INSTALL_PREFIX=${MINGW_PREFIX} \
    -DBUILD_TESTS=OFF \
    -DVUL_WERROR=OFF \
    ../${_realname}-vulkan-sdk-${pkgver}

  ${MINGW_PREFIX}/bin/cmake.exe --build .
}

package() {
  cd "${srcdir}"/build-${MSYSTEM}
  DESTDIR="${pkgdir}" ${MINGW_PREFIX}/bin/cmake.exe --install .

  install -Dm644 "${srcdir}"/${_realname}-vulkan-sdk-${pkgver}/LICENSE.md "${pkgdir}"${MINGW_PREFIX}/share/licenses/vulkan-utility-libraries/LICENSE
}
