# Contributor: Alex Klinkhamer <about.alpinelinux@grencez.dev>
# Maintainer: Alex Klinkhamer <about.alpinelinux@grencez.dev>
pkgname=fildesh
pkgver=0.2.0
pkgrel=0
pkgdesc="Shell tool for creating nonlinear Unix pipelines"
url="https://github.com/fildesh/fildesh"
arch="all"
license="ISC"
makedepends="
	cmake
	samurai
"
subpackages="
	$pkgname-doc::noarch
	$pkgname-vim::noarch
"
source="https://github.com/fildesh/fildesh/releases/download/v$pkgver/fildesh-$pkgver.tar.gz"

build() {
	cmake -B build -G Ninja \
		-DCMAKE_BUILD_TYPE=MinSizeRel \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DBUILD_TESTING="$(want_check && echo ON || echo OFF)"
	cmake --build build
}

check() {
	ctest --test-dir build
}

package() {
	DESTDIR="$pkgdir" cmake --install build --component bin
	DESTDIR="$pkgdir" cmake --install build --component share_vim
	install -m 644 -D LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
}

vim() {
	pkgdesc="$pkgname (vim support)"
	install_if="$pkgname=$pkgver-r$pkgrel vim"

	amove usr/share/vim
}

sha512sums="
22fb163d6cb2d5971e11cdf409e77a8b0a83be7a14f5718ac6f4c8c9783e219f5171517615805434b9b3171829b5b3d4287c4844b62a64adf7cb21dd34229b09  fildesh-0.2.0.tar.gz
"
