# Maintainer: kpcyrd <git@rxv.cc>
pkgname=wasm-bindgen
pkgver=0.2.95
pkgrel=0
pkgdesc="Interoperating JS and Rust code"
url="https://github.com/rustwasm/wasm-bindgen"
arch="all"
license="Apache-2.0"
depends="cargo nodejs rust-wasm"
makedepends="
	cargo-auditable
	"
source="https://github.com/rustwasm/wasm-bindgen/archive/refs/tags/$pkgver/wasm-bindgen-$pkgver.tar.gz
	Cargo-$pkgver.lock::https://gitlab.archlinux.org/archlinux/packaging/packages/wasm-bindgen/-/raw/$pkgver-1/Cargo.lock
	"
options="net !check" # most tests fail outside of x86_64

prepare() {
	# https://github.com/rustwasm/wasm-bindgen/issues/1819
	cp "$srcdir/Cargo-$pkgver.lock" Cargo.lock

	default_prepare

	cargo fetch --target="$CTARGET" --locked
}

build() {
	cd crates/cli
	cargo auditable build --release --frozen
}

check() {
	cd crates/cli
	cargo test --frozen
}

package() {
	install -Dm755 -t "$pkgdir"/usr/bin \
		target/release/wasm-bindgen \
		target/release/wasm-bindgen-test-runner \
		target/release/wasm2es6js
}

sha512sums="
7a4bffd966721072985b2d403a826d5411d1aae62512020bc88762b3731339e494d840ec0b5326641b7d8a7bdcf769e4970b137d96eb8c3670a2d9901f8ff1d3  wasm-bindgen-0.2.95.tar.gz
129f2a182cdd87ed59a8616f7d757283ec215dfd7f72d27aeb9b39d7628e98d064b6e5a55e62481fb78474a7134c8181ac2143bbe02fae6507e5fdb047deae7f  Cargo-0.2.95.lock
"
