# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=nimble
pkgver=0.14.2
pkgrel=0
pkgdesc="Package manager for the Nim programming language"
url="https://github.com/nim-lang/nimble"
arch="all !s390x" # blocked by nim
license="BSD-3-Clause"
depends="nim libssl3"
subpackages="$pkgname-bash-completion $pkgname-zsh-completion"
source="https://github.com/nim-lang/nimble/archive/v$pkgver/nimble-$pkgver.tar.gz"
# TODO: Fix tests
options="!check"

prepare() {
	default_prepare

	# XXX: This is a workaround for missing option in unittest to skip/exclude
	# particular suite(s).
	# - Remove test suite "issues" - some tests require additional dependencies
	#   and/or are too complex and takes eternity to complete.
	# - Additionaly, we have to remove test "compile without warnings" because
	#   it runs tester.nim with linter; after we removed the "issues" test
	#   suite, there are some unused functions, so this test doesn't pass.
	sed -i \
		-e '/^suite "issues":/,/^suite /d' \
		-e '/test "compilation without warnings":/,/test "/d' \
		tests/tester.nim
}

build() {
	nim compile -d:release src/nimble
}

check() {
	unset GIT_CEILING_DIRECTORIES
	cd tests
	nim c -r tester
}

package() {
	install -D -m 755 src/nimble "$pkgdir"/usr/bin/nimble

	install -D -m 644 nimble.zsh-completion \
		"$pkgdir"/usr/share/zsh/site-functions/_nimble

	install -D -m 644 nimble.bash-completion \
		"$pkgdir"/usr/share/bash-completion/completions/nimble
}

sha512sums="
cbfb0274fb8644f4b1e453275c3544718958370c7cde0d0a60d3bd1ce5e3a3ec980f9a330c9755d02833134be5898da964dfe71e9a3f8aea9a88230391187a63  nimble-0.14.2.tar.gz
"
