# Packager = Tuxcore <dev@tuxcore.org> 
pkgbase=dav1d
pkgname=(dav1d dav1d-doc)
pkgver=1.5.0
pkgrel=1
pkgdesc='AV1 cross-platform decoder focused on speed and correctness'
url='https://code.videolan.org/videolan/dav1d/'
arch=(x86_64)
license=(BSD-2-Clause)
makedepends=(
  doxygen
  glibc
  graphviz
  meson
  nasm
  ninja
  xxhash
)
source=(
  https://downloads.videolan.org/pub/videolan/${pkgname}/${pkgver}/${pkgname}-${pkgver}.tar.xz{,.asc}
  https://code.videolan.org/videolan/dav1d-test-data/-/archive/${pkgver}/dav1d-test-data-${pkgver}.tar.gz
)
sha512sums=('774881d27d045f468a8617317fa751e1ce452a15c6d6c2c93c3dd3c3544d6b2b91b0c3eb5ff379f113c26b27a02dc4b54d0751b083dcbcb18bb96c66a6504acb'
            'SKIP'
            '0102abdf3310c53a09c9ae9a8bf7e662402f31ecb41624f70a6557a618e384b38dedb088241b6887a5b93573631b32c778fec90e82236c2192ae18d5914bcae4')
b2sums=('7cf75b9de834c77a8012fb560fadca339d0faa0ab92073fd0119f0c5ccbb19017aa271a1aa0939aa698a52e2285b79a956021776a702afe2a7de131ce92d7241'
        'SKIP'
        '4d44ffab66de96da059ceacaa1e7c5df63f362492cb9f29af44b7a9b0f1c75da1c96fa64263c23b891a7b17fe78eefcf263fb6917b499de3814bbff3b482ea3c')
validpgpkeys=(
  '65F7C6B4206BD057A7EB73787180713BE58D1ADC' # VideoLAN Release Signing Key
)

prepare() {
  cd ${pkgbase}-${pkgver}
  ln -s "${srcdir}/dav1d-test-data-${pkgver}" tests/dav1d-test-data
}

build() {
  cd ${pkgbase}-${pkgver}
  arch-meson \
    -Dtestdata_tests=true \
    -Denable_docs=true \
    build
  ninja -C build all doc/html
}

check() {
  cd ${pkgbase}-${pkgver}/build
  meson test
}

package_dav1d() {
  depends=('glibc')
  provides=('libdav1d.so')
  optdepends=('dav1d-doc: HTML documentation')

  cd ${pkgbase}-${pkgver}
  DESTDIR="${pkgdir}" ninja -C build install
  install -Dm 644 README.md CONTRIBUTING.md NEWS -t "${pkgdir}/usr/share/doc/${pkgname}"
  install -Dm 644 COPYING -t "${pkgdir}/usr/share/licenses/${pkgname}"
}

package_dav1d-doc() {
  pkgdesc+=" (documentation)"

  cd ${pkgbase}-${pkgver}
  install -d "${pkgdir}/usr/share/doc/${pkgbase}"
  cp -r build/doc/html -t "${pkgdir}/usr/share/doc/${pkgbase}"
  install -Dm 644 COPYING -t "${pkgdir}/usr/share/licenses/${pkgname}"
}

# vim: ts=2 sw=2 et:
