# Maintainer: Maxime Gauduin <alucryd@archlinux.org>
# Contributor: Daniel Bermond <dbermond@archlinux.org>
# Contributor: Chocobo1 <chocobo1@archlinux.net>

pkgname=rav1e
pkgver=0.7.1
pkgrel=1.1
pkgdesc='An AV1 encoder focused on speed and safety'
arch=(x86_64 powerpc64le powerpc64 powerpc riscv64)
url=https://github.com/xiph/rav1e/
license=(custom:BSD)
depends=(
  gcc-libs
  glibc
)
makedepends=(
  cargo-c
  git
  rust
)
makedepends_x86_64=(
  nasm
)
provides=(librav1e.so)
_tag=a8d05d0c43826a465b60dbadd0ab7f1327d75371
source=(
  git+https://github.com/xiph/rav1e.git#tag=${_tag}
  Cargo-rav1e-${pkgver}.lock::https://github.com/xiph/rav1e/releases/download/v${pkgver}/Cargo.lock
)
b2sums=('SKIP'
        '7cbeaff87ca4e9db469be06cbead0c5b05af2064d6d5f12f97f5999992017b66a24bc19ed4eaf69f7d6579732f843f3e93f30d9581b8c8344728d3e3773a0f79')

pkgver() {
  cd rav1e
  git describe --tags | sed 's/^v//'
}

prepare() {
  cp -f Cargo-rav1e-${pkgver}.lock rav1e/Cargo.lock
  cargo fetch \
    --locked \
    --manifest-path rav1e/Cargo.toml
}

build() {
  cargo build \
    --release \
    --frozen \
    --no-default-features \
    --features binaries,asm,threading,signal_support \
    --manifest-path rav1e/Cargo.toml
  cargo cbuild \
    --release \
    --frozen \
    --no-default-features \
    --features binaries,asm,threading,signal_support \
    --prefix=/usr \
    --manifest-path rav1e/Cargo.toml
}

check() {
  cargo test \
    --release \
    --frozen \
    --no-default-features \
    --features binaries,asm,threading,signal_support \
    --manifest-path rav1e/Cargo.toml
}

package() {
  cd rav1e
  cargo install \
    --frozen \
    --no-default-features \
    --features binaries,asm,threading,signal_support \
    --offline \
    --no-track \
    --path . \
    --root "${pkgdir}"/usr
  cargo cinstall \
    --release \
    --frozen \
    --no-default-features \
    --features binaries,asm,threading,signal_support \
    --prefix /usr \
    --destdir "${pkgdir}"
  install -Dm 644 LICENSE PATENTS -t "${pkgdir}"/usr/share/licenses/rav1e/
}

# vim: ts=2 sw=2 et:
