# Packager = Tuxcore <dev@tuxcore.org> 
pkgbase=dav1d
pkgname=(dav1d dav1d-doc)
pkgver=1.4.3
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=('6f3233acfb7d248155ac4beb237fe48186fdfb378820f0b15a5ca54a5642a63ebae48446075f10c6be77a8b9a95ddf41c6709af21936af793f1bbc28a2ef4bd8'
            'SKIP'
            '25ad2f6253b931cab7f718d9f7a8e09b58dcce0b685bb98032dfd35b26240cf124341edbc2b2e2c3c0d4c9db06e82db5c6887691d2e2f02172f684ed5af754da')
b2sums=('e24cf033f94b49f917fa70e17438b0811c85042d5774a605343ca13c979b81b11a98b8453999e4796f4674b15db150c80606ddeae6a648f20f2f4fde32dfad9c'
        'SKIP'
        'b6a8e2589806ab97538ecf9abe3acce62db176659e4a443124af3ee6f30216790506ced45402bcf323b6ea50e5e9777a867a61b2a129bd2ed6387a6dde3dbaa7')
  '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:
