# Contributor: TBK <alpine@jjtc.eu>
# Maintainer: TBK <alpine@jjtc.eu>
pkgname=libimagequant
pkgver=4.2.2
pkgrel=0
pkgdesc="Rust library for high-quality conversion of RGBA images to 8-bit indexed-color (palette) images"
url="https://pngquant.org/lib/"
arch="all"
license="GPL-3.0-or-later"
depends_dev="$pkgname=$pkgver-r$pkgrel"
makedepends="cargo cargo-auditable cargo-c"
subpackages="$pkgname-dev"
source="$pkgname-$pkgver.tar.gz::https://github.com/ImageOptim/libimagequant/archive/$pkgver.tar.gz
	Cargo.lock
	"
builddir="$srcdir/$pkgname-$pkgver/imagequant-sys"
options="net"

case "$CARCH" in
x86)
	# tests fail
	options="$options !check"
	;;
*)
	;;
esac

prepare() {
	default_prepare

	ln -sfv "$srcdir"/Cargo.lock ../Cargo.lock

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

build() {
	cargo auditable cbuild --release \
		--frozen \
		--prefix /usr \
		--library-type cdylib
}

check() {
	cargo test --frozen
}

package() {
	cargo auditable cinstall --release \
		--frozen \
		--prefix /usr \
		--destdir "$pkgdir" \
		--library-type cdylib
}

sha512sums="
31bd79024abc1fd884461f8f422d6eac1f5786ce347ac3c517e9cb66f289ad1ace0e3a25c55c7b7384badb2545174871464d60f1238ed2deb1f521d5f3ede96b  libimagequant-4.2.2.tar.gz
476c698dd00d2c288b0984d240a06c962d3e45c9477842b7bad6d2cf04eddf1859338887af0a98de7ca0bb011a398ab7079572eef330e6759d1c471a4bb2577f  Cargo.lock
"
