# Contributor: Leo <thinkabit.ukim@gmail.com>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=fd
pkgver=10.2.0
pkgrel=0
pkgdesc="Simple, fast, user-friendly alternative to find"
url="https://github.com/sharkdp/fd"
# s390x: fails to build nix crate
arch="all !s390x"
license="MIT Apache-2.0"
makedepends="cargo cargo-auditable"
checkdepends="coreutils"
options="net"
subpackages="
	$pkgname-doc
	$pkgname-bash-completion
	$pkgname-fish-completion
	$pkgname-zsh-completion
	"
source="https://github.com/sharkdp/fd/archive/v$pkgver/fd-$pkgver.tar.gz"

export CARGO_PROFILE_RELEASE_OPT_LEVEL="z"

prepare() {
	default_prepare

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

build() {
	cargo auditable build --frozen --release
	make completions

	# Rebuild without completions (-0.9 MiB).
	cargo auditable build --frozen --release --no-default-features --features use-jemalloc
}

check() {
	cargo test --frozen
}

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

	install -D -m644 doc/fd.1 -t "$pkgdir"/usr/share/man/man1/

	install -D -m644 autocomplete/fd.bash "$pkgdir"/usr/share/bash-completion/completions/fd
	install -D -m644 autocomplete/fd.fish "$pkgdir"/usr/share/fish/vendor_completions.d/fd.fish
	install -D -m644 autocomplete/_fd "$pkgdir"/usr/share/zsh/site-functions/_fd
}

sha512sums="
db7a41d0dd448d73a88f7920b0d67d5d99864fef0a7d64a91523a55af9fd745e6520df8aee808f4131a07acd34730571d94a20e1e6aa1336c6f3caaab593d4ab  fd-10.2.0.tar.gz
"