pkgname=librashader
pkgver=0.2.0~beta.2
pkgrel=0
pkgdesc="RetroArch shader runtime"
arch=('x86_64' 'aarch64')
url="https://github.com/SnowflakePowered/librashader"
license=('MPL-2.0')
groups=('')
depends=('gcc' 'rust' 'patchelf' 'ninja')
provides=("$pkgname=$pkgver" 'librashader.so')
backup=('')
source=("$pkgname-$pkgver.tar.xz" 'vendor.tar.xz' 'cargo_config')
cksums=("SKIP" "SKIP" "SKIP") 
profile="optimized"

build() {
  cd $pkgname-$pkgver
  mkdir .cargo               
  cp "$srcdir/cargo_config" .cargo/config
  cp -r "$srcdir/vendor" "vendor"
  cp "$srcdir/Cargo.lock" "Cargo.lock"
  RUSTC_BOOTSTRAP=1 cargo run -p librashader-build-script -- --profile ${profile}

}

package() {
  mkdir -p $pkgdir/usr/lib
  mkdir -p $pkgdir/usr/include/librashader
  patchelf --set-soname librashader.so.1 $srcdir/$pkgname-$pkgver/target/$profile/librashader.so
  install -m 0755 $srcdir/$pkgname-$pkgver/target/${profile}/librashader.so $pkgdir/usr/lib/librashader.so
  cp $srcdir/$pkgname-$pkgver/target/${profile}/librashader.h $pkgdir/usr/include/librashader/librashader.h
  cp $srcdir/$pkgname-$pkgver/include/librashader_ld.h $pkgdir/usr/include/librashader/librashader_ld.h
}