# Maintainer: David Demelier <markand@malikania.fr

_realname=vera++
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=1.3.0
pkgrel=12
pkgdesc="A programmable tool for verification, analysis and transformation of C++ source code (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url="https://bitbucket.org/verateam/vera"
license=('spdx:BSL-1.0')
depends=("${MINGW_PACKAGE_PREFIX}-tcl"
         "${MINGW_PACKAGE_PREFIX}-boost-libs"
         "${MINGW_PACKAGE_PREFIX}-python")
makedepends=("${MINGW_PACKAGE_PREFIX}-cc"
             "${MINGW_PACKAGE_PREFIX}-cmake"
             "${MINGW_PACKAGE_PREFIX}-ninja"
             "${MINGW_PACKAGE_PREFIX}-boost")
source=(https://bitbucket.org/verateam/vera/downloads/${_realname}-${pkgver}.tar.gz
        0001-fix_python_detection_issues.patch
        0002-link-to-shared-boost.patch)
sha256sums=('9415657a09438353489db10ca860dd6459e446cfd9c649a1a2e02268da66f270'
            '9936765db63feb6371200bf88d14a68a06fac233d76d3d8aba74ce4fe0000427'
            '51caadf3f0490240c2e9673acaddfd367992e7202aceebb817ec7b164a596c57')

prepare() {
  cd "${srcdir}/${_realname}-${pkgver}"
  patch -Np0 -i "${srcdir}/0001-fix_python_detection_issues.patch"
  patch -Np1 -i "${srcdir}/0002-link-to-shared-boost.patch"
}

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

  MSYS2_ARG_CONV_EXCL="-DCMAKE_INSTALL_PREFIX=" \
  ${MINGW_PREFIX}/bin/cmake.exe \
    -G"Ninja" \
    -DCMAKE_INSTALL_PREFIX=${MINGW_PREFIX} \
    -DVERA_LUA=Off \
    -DVERA_USE_SYSTEM_BOOST=ON \
    -DPYTHON_EXECUTABLE=${MINGW_PREFIX}/bin/python \
    ../${_realname}-${pkgver}

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

package() {
  cd build-${MSYSTEM}
  DESTDIR="${pkgdir}" ${MINGW_PREFIX}/bin/cmake --install .
  install -Dm644 "${srcdir}"/${_realname}-${pkgver}/LICENSE_1_0.txt \
    "${pkgdir}"${MINGW_PREFIX}/share/licenses/${_realname}/LICENSE
}
