# Maintainer: Jason Staten <code.alpine@jxs.me>
pkgname=wazero
pkgver=1.6.0
pkgrel=5
pkgdesc="WebAssembly Core Specification 1.0 and 2.0 compliant runtime"
url="https://wazero.io"
# Tests fail on 32-bit and ppc64le architectures
arch="x86_64 aarch64"
license="Apache-2.0"
makedepends="go"
source="$pkgname-$pkgver.tar.gz::https://github.com/tetratelabs/wazero/archive/refs/tags/v$pkgver.tar.gz
	debug-test-path.patch
	"

build() {
	go build \
		-ldflags "-X github.com/tetratelabs/wazero/internal/version.version=$pkgver" \
		./cmd/wazero
}

check() {
	# gojs/goos -buildmode=pie not supported on js/wasm
	export GOFLAGS="${GOFLAGS/-buildmode=pie}"
	# integration_test/vs/compiler requires real paths for relative read
	export GOFLAGS="${GOFLAGS/-trimpath}"

	# Test_crypto is failing on Go 1.22, and gojs will be removed in
	# wazero 1.7.0: https://github.com/tetratelabs/wazero/pull/2027
	go test -skip Test_crypto github.com/tetratelabs/wazero/internal/...
}

package() {
	install -Dm755 wazero -t "$pkgdir"/usr/bin
}

sha512sums="
12b86ceda21c382ab4e4e071a2a8972556df41f580b2e24d383150907d9840cfbb471d823709a1f520dd20066095c06409bc83f6bd45c3315fa9fc9fac7b2efb  wazero-1.6.0.tar.gz
289e501d3604c7b4a2907d6b93c7ee93751c3d8dfe0565ec1bf9d275734cd973d03713056405d0adaa7a762a5748f47664fd24b900540ff5b9383fe54a72ac88  debug-test-path.patch
"
