# Maintainer: Alexey Pavlov <Alexpux@gmail.com>

_realname=fxc2
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
provides=("${MINGW_PACKAGE_PREFIX}-${_realname}-git")
conflicts=("${MINGW_PACKAGE_PREFIX}-${_realname}-git")
replaces=("${MINGW_PACKAGE_PREFIX}-${_realname}-git")
pkgver=r19.807d26f
_commit='807d26f4e4e9e9d0d0d6c1e05493b28eafb20e91'
pkgrel=1
pkgdesc="A wine-runnable version of Microsofts Shader Compiler fxc (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clangarm64')
url='https://github.com/mozilla/fxc2/'
license=('spdx:MPL-2.0')
makedepends=("${MINGW_PACKAGE_PREFIX}-cc"
             "git")
source=(${_realname}::git+"https://github.com/mozilla/fxc2.git#commit=${_commit}")
sha256sums=('SKIP')

pkgver() {
  cd "${srcdir}/${_realname}"
  printf "r%s.%s" "$(git rev-list --count $_commit)" "$(git rev-parse --short $_commit)"
}

prepare() {
  cd "${srcdir}"/${_realname}
}

build() {
  [[ -d build-${MSYSTEM} ]] && rm -rf build-${MSYSTEM}
  cp -rf ${_realname} build-${MSYSTEM}
  cd build-${MSYSTEM}

  ${MINGW_PREFIX}/bin/c++ -static fxc2.cpp -o fxc.exe
}

package() {
  cd "${srcdir}"/build-${MSYSTEM}
  mkdir -p "${pkgdir}"${MINGW_PREFIX}/bin
  cp fxc.exe "${pkgdir}"${MINGW_PREFIX}/bin/
}
