# Maintainer: Quentin Michaud <mh4ckt3mh4ckt1c4s@archlinux.org>

pkgname=wasm-tools
pkgver=1.245.1
pkgrel=1
pkgdesc="Low level tooling for WebAssembly in Rust"
arch=("x86_64" "aarch64")
url="https://github.com/bytecodealliance/wasm-tools"
license=("Apache-2.0")
depends=("glibc" "gcc-libs")
# Update using ./retrieve-testsuite-commit.sh <pkgver>
_wasm_testsuite_commit=e999a1051925895022ab06abc25b23ca300ab0d0
makedepends=("cargo")
source=(
	"$pkgname-$pkgver.tar.gz::https://github.com/bytecodealliance/$pkgname/archive/refs/tags/v$pkgver.tar.gz"
	"wasm-testsuite-$_wasm_testsuite_commit.tar.gz::https://github.com/WebAssembly/testsuite/archive/$_wasm_testsuite_commit.tar.gz"
)
sha256sums=('f8fc02ceec50f0188e4128159535e6c4195594e74c56ecc1db3113e62feb477d'
            'e289c03b4586b92f5e59e30078c4ea96d79fbdc59d993e866c694893473c315c')

options_aarch64=(!lto)

prepare() {
    cd "$pkgname-$pkgver"
    rm -r tests/testsuite
    cp -r "$srcdir/testsuite-$_wasm_testsuite_commit" tests/testsuite
    cargo fetch --locked --target "$(rustc --print host-tuple)"
}

build() {
    cd "$pkgname-$pkgver"
    cargo build --frozen --release --all-features --bin wasm-tools
}

check() {
    cd "$pkgname-$pkgver"
    cargo test --frozen
}

package() {
    cd "$pkgname-$pkgver"
    install -Dm0755 -t "$pkgdir/usr/bin/" "target/release/$pkgname"
}
