# Maintainer: Antoine Martin (ayakael) <dev@ayakael.net>
# Contributor: Antoine Martin (ayakael) <dev@ayakael.net>

pkgname=libsignal-client
_pkgname=libsignal
_libname=libsignal_jni
pkgver=0.19.1
pkgrel=0
pkgdesc='Library for the Signal Protocol.'
url="https://github.com/signalapp/$_pkgname"
makedepends="
	clang
	clang-libs
	cmake
	make
	cargo
	yarn
	npm
	"
arch="x86 x86_64 armhf armv7 aarch64"
license="GPL-3.0-only"
source="$pkgname-$pkgver.tar.gz::https://github.com/signalapp/$_pkgname/archive/refs/tags/v$pkgver.tar.gz"
builddir="$srcdir"/$_pkgname-$pkgver

prepare() {
	default_prepare

	# Use the default system rust toolchain
	rm -f rust-toolchain
}

build() {
	cd node

	yarn install
	yarn tsc
}

check() {
	cd node
	yarn test
}

package() {
	install -m755 -d "${pkgdir}/usr/share/java/${pkgname}" "${pkgdir}/usr/lib"

	install -Dm644 "java/client/build/libs/libsignal-client-${pkgver}.jar" "$pkgdir/usr/share/java/$pkgname/$pkgname.jar"
	install -Dm644 "target/release/${_libname}.so" "$pkgdir/usr/lib/"
}
sha512sums="
389611d862446222c87c777804d26cda74ad2c69f6476f66de48263c40433517d05e32b73b31c86ac0b93a10595453f466b8ed069753a7044858a6734255bb34  libsignal-client-0.19.1.tar.gz
"
