pkgname=brotli
pkgver=1.1.0
pkgdesc='Generic-purpose lossless compression algorithm'
homepage='https://github.com/google/brotli'
arch=('x86_64')
license=('MIT')
makedepends=(
  cmake
  #python-setuptools
  #python-build
  #python-installer
  #python-wheel
  #python-pkgconfig
)
sources=("${pkgname}-${pkgver}.tar.gz")
urls=("https://github.com/google/${pkgname}/archive/v${pkgver}.tar.gz")
md5sums=("3a6a3dba82a3604792d3cb0bd41bca60")

src_prepare() {
  tar -xf ${distdir}/${sources[0]} --strip-components=1
}

src_build() {
  #python -m build --wheel --no-isolation
  cmake -S . -B build \
    -DCMAKE_BUILD_TYPE=Release \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DBUILD_SHARED_LIBS=True \
    -DCMAKE_C_FLAGS="$CFLAGS -ffat-lto-objects"
  cmake --build build -v
}

src_check() {
  #local python_version=$(python -c 'import sys; print("".join(map(str, sys.version_info[:2])))')
  #PYTHONPATH="$PWD/bin/lib.linux-x86_64-cpython-${python_version}" python -m unittest discover python "*_test.py"
  cd build
  ctest --output-on-failure --stop-on-failure -j${PARALLEL_JOBS}
}

src_install() {
  DESTDIR="$pkgdir" cmake --install build
  #python -m installer --destdir="$pkgdir" dist/*.whl
  install -Dm 644 LICENSE -t "$pkgdir/usr/share/licenses/$pkgname"
}

# vim:ft=sh syn=sh et sw=2:
