# Template file for 'resvg'
pkgname=resvg
version=0.48.1
revision=1
build_style=cargo
configure_args="--workspace --exclude=resvg-capi"
hostmakedepends="cargo-c"
short_desc="SVG rendering library written in Rust"
maintainer="Orphaned <orphan@voidlinux.org>"
license="Apache-2.0 OR MIT"
homepage="https://github.com/linebender/resvg"
changelog="https://raw.githubusercontent.com/linebender/resvg/refs/heads/main/CHANGELOG.md"
distfiles="https://github.com/linebender/resvg/archive/refs/tags/v${version}.tar.gz"
checksum=40dafea6b4b9d01e9d28b6d49f1e912daf3e9055676ad9179a5a2db6e7386945

post_build() {
	(
		cd crates/c-api
		cargo auditable cbuild --release --target ${RUST_TARGET} \
		--library-type cdylib --library-type staticlib \
		--destdir="${DESTDIR}" --prefix="/usr" --locked
	)
}

do_install() {
	for _bin in {re,u}svg; do
		vbin target/${RUST_TARGET}/release/${_bin}
	done

	vlicense LICENSE-APACHE
	vlicense LICENSE-MIT

	# Install C library
	(
		cd crates/c-api
		cargo auditable cinstall --release --target ${RUST_TARGET} \
		--library-type cdylib --library-type staticlib \
		--destdir="${DESTDIR}" --prefix="/usr" --offline --locked
	)
}

libresvg0_package() {
	short_desc+=" - resvg library"
	pkg_install() {
		 vmove "usr/lib/libresvg.so.*"
	}
}

libresvg-devel_package() {
	depends="libresvg0-${version}_${revision}"
	short_desc+=" - development files"
	pkg_install() {
		vmove usr/include
		vmove usr/lib/pkgconfig
		vmove "usr/lib/*.a"
		vmove "usr/lib/*.so"
	}
}
