# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=swc
pkgver=1.5.7
pkgrel=0
pkgdesc="A super-fast TypeScript / JavaScript compiler written in Rust"
url="https://swc.rs"
# riscv64: it would take eternity to build
arch="all !riscv64"
license="Apache-2.0"
makedepends="cargo cargo-auditable"
source="https://github.com/swc-project/swc/archive/v$pkgver/swc-$pkgver.tar.gz
	bump-libc.patch"
builddir="$srcdir/$pkgname-$pkgver/bindings"
# !check: TODO: run tests
# net: fetch dependencies
options="!check net"

prepare() {
	default_prepare

	# This is unwanted and breaks build on ARM.
	rm ../.cargo/config.toml

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

build() {
	cargo auditable build -p swc_cli --release --locked
}

package() {
	install -D -m755 target/release/swc -t "$pkgdir"/usr/bin/
}

sha512sums="
55e74071d4f25eeba162d3271c0d87a9f332ac33b4e12abbe0a1fc7cfc5eac552b69941d3efdf854791faa3455ef2565bbc81acb62abc088611818bfc28caaab  swc-1.5.7.tar.gz
1c1ebfda1a1a2ab14bc93a243cf00288866faaf7e9f1ef8bb6775b59798229f231725f7ef5cbe98d4c28215aa85cd80dd10ff38c25acee8eb42d47eb1f0c41ed  bump-libc.patch
"
