# Maintainer: Marcelo Duarte https://github.com/marcelotduarte

_realname=cx-logging
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
pkgver=3.0
pkgrel=3
pkgdesc="Python and C interfaces for logging (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32')
license=('PSF')
url="https://github.com/anthony-tuininga/cx_Logging"
depends=("${MINGW_PACKAGE_PREFIX}-python")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-setuptools")
options=('staticlibs' 'strip' '!debug')
source=(cx_Logging-${pkgver}.tar.gz::https://pypi.io/packages/source/c/cx_Logging/cx_Logging-${pkgver}.tar.gz
        0000-include-cx-logging-h.patch
        0001-setup-remove-compiler-option.patch)
sha256sums=('ba8a7465facf7b98d8f494030fb481a2e8aeee29dc191e10383bb54ed42bdb34'
            '265422f8fe1f1204b372d291d93048f8f63169daa744990a58f704af8d4b8620'
            '2e5c37717174bab363eb1efdaa368faeb9ad5f7812409915284313eed3322ce7')

prepare() {
  cd "${srcdir}/cx_Logging-${pkgver}"

  # patch cx_Logging 3.0 - temporary fix until 3.1
  patch -p1 -i "${srcdir}/0000-include-cx-logging-h.patch"

  # For clang
  if [[ ${MINGW_PACKAGE_PREFIX} == *-clang-* ]]; then
    patch -p1 -i "${srcdir}/0001-setup-remove-compiler-option.patch"
  fi

  cd "${srcdir}"
  rm -Rf python-${_realname}-${CARCH}
  cp -a cx_Logging-${pkgver} python-${_realname}-${CARCH}
}

package() {
  local _mingw_prefix=$(cygpath -wm ${MINGW_PREFIX})
  cd python-${_realname}-${CARCH}
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
    ${MINGW_PREFIX}/bin/python setup.py install --prefix=${MINGW_PREFIX} \
    --root="${pkgdir}" --optimize=1
}
