# Maintainer: Sven-Hendrik Haase <svenstaro@archlinux.org>
# Contributor: envolution
# Contributor: David Garfias <dgarfiasme at gmail dot com>
# shellcheck shell=bash disable=SC2034,SC2154
pkgname=rutabaga-ffi
pkgver=0.1.71
pkgrel=2
pkgdesc="Cross-platform, open-source, Rust-based GPU paravirtualization"
arch=("x86_64" "aarch64")
url="https://github.com/magma-gpu/rutabaga_gfx"
license=(BSD-3-Clause)
source=("$pkgname-$pkgver.tar.gz::https://github.com/magma-gpu/rutabaga_gfx/archive/refs/tags/v${pkgver}.tar.gz")
depends=(glibc gcc-libs virglrenderer gfxstream)
makedepends=(rust meson git)
sha256sums=('123e5e00417b8600a643b55145fe8a1bcdf3091df0249b5245a7777e85b65696')

# Use debug
export CARGO_PROFILE_RELEASE_DEBUG=2 CARGO_PROFILE_RELEASE_STRIP=false

# Use LTO
export CARGO_PROFILE_RELEASE_LTO=true CARGO_PROFILE_RELEASE_CODEGEN_UNITS=1

build() {
  cd rutabaga_gfx-$pkgver/ffi
  arch-meson . build -Dgfxstream=true --buildtype=release
  meson compile -C build
}

package() {
  cd rutabaga_gfx-$pkgver/ffi
  meson install -C build --destdir "$pkgdir"
  install -Dm644 LICENSE "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
  # force symlinks to avoid warnings
  cd "$pkgdir"/usr/lib
  ln -sf librutabaga_gfx_ffi.so.0.1.6 librutabaga_gfx_ffi.so.0
  ln -sf librutabaga_gfx_ffi.so.0 librutabaga_gfx_ffi.so
}
# vim:set ts=2 sw=2 et:
