# Maintainer: David Demelier <markand@malikania.fr
_realname=vera++
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=1.3.0
pkgrel=3
pkgdesc="A programmable tool for verification, analysis and transformation of C++ source code"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32')
url="https://bitbucket.org/verateam/vera"
license=('custom:boost')
depends=(${MINGW_PACKAGE_PREFIX}-tcl
         ${MINGW_PACKAGE_PREFIX}-boost
         ${MINGW_PACKAGE_PREFIX}-python)
makedepends=(${MINGW_PACKAGE_PREFIX}-cmake)
source=(https://bitbucket.org/verateam/vera/downloads/${_realname}-${pkgver}.tar.gz
        0001-fix_python_detection_issues.patch)
sha256sums=('9415657a09438353489db10ca860dd6459e446cfd9c649a1a2e02268da66f270'
            '29411f71eb1ee1f727253ea3893b6556e7c3b2dfa19da5f0b0a2fc955fc08f8c')

prepare() {
  cd "${srcdir}/${_realname}-${pkgver}"
  patch -Np0 -i "${srcdir}/0001-fix_python_detection_issues.patch"
}

build() {
  [[ -d build-${MINGW_CHOST} ]] && rm -r build-${MINGW_CHOST}
  mkdir build-${MINGW_CHOST} && cd build-${MINGW_CHOST}

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

  make
}

package() {
  cd build-${MINGW_CHOST}
  make DESTDIR="${pkgdir}" install
}
