# Contributor: Kaspar Schleiser <kaspar@schleiser.de>
# Maintainer: Kaspar Schleiser <kaspar@schleiser.de>
pkgname=laze
pkgver=0.1.31
pkgrel=0
pkgdesc="laze is a build system based on Ninja, aiming to be the next goto-alternative to make"
url="https://laze-build.org"
arch="all"
license="Apache-2.0"
depends="ninja"
makedepends="cargo cargo-auditable"
checkdepends="xz"
subpackages="$pkgname-doc
	$pkgname-bash-completion
	$pkgname-fish-completion
	$pkgname-zsh-completion
	"
source="https://github.com/kaspar030/laze/archive/$pkgver/laze-$pkgver.tar.gz"

prepare() {
	default_prepare
	cargo fetch --target="$CTARGET" --locked
}

build() {
	cargo auditable build --release --frozen
}

check() {
	cargo test --frozen
}

package() {
	install -Dm755 "target/release/laze" "$pkgdir/usr/bin/laze"

	# create man pages
	mkdir -p tmp/man tmp/completions
	target/release/laze manpage tmp/man

	install -Dm644 "tmp/man/laze.1" "$pkgdir/usr/share/man/man1/laze.1"
	install -Dm644 "tmp/man/laze-build.1" "$pkgdir/usr/share/man/man1/laze-build.1"
	install -Dm644 "tmp/man/laze-clean.1" "$pkgdir/usr/share/man/man1/laze-clean.1"

	# create completions
	for shell in bash zsh fish; do
		target/release/laze -Ctmp/completions completion --generate $shell \
			> tmp/completions/$shell
	done

	install -Dm644 "tmp/completions/bash" \
		"$pkgdir/usr/share/bash-completion/completions/laze"
	install -Dm644 "tmp/completions/fish" \
		"$pkgdir/usr/share/fish/vendor_completions.d/laze.fish"
	install -Dm644 "tmp/completions/zsh" \
		"$pkgdir/usr/share/zsh/site-functions/_laze"
}

sha512sums="
1225afcfc269c6f1df874bdea6d5a6f1f409b814739bab3b2e18f4eb68977d3ba067c09e4b055a38c384f44e5f0bcf6d9ab60e9998d36a61286bc588f2bdbc03  laze-0.1.31.tar.gz
"
