# Contributor: Mathias LANG <pro.mathias.lang@gmail.com>
# Maintainer: Celeste <cielesti@protonmail.com>
maintainer="Celeste <cielesti@protonmail.com>"
pkgname=dub
pkgver=1.40.0
pkgrel=0
pkgdesc="Package and build management system for D"
url="https://code.dlang.org/"
arch="x86_64 aarch64 loongarch64"
license="MIT"
depends="libcurl"
makedepends="chrpath ldc bash curl-dev"
subpackages="$pkgname-doc $pkgname-zsh-completion"
source="$pkgname-$pkgver.tar.gz::https://github.com/dlang/dub/archive/v$pkgver.tar.gz"

build() {
	# The build script needs a DMD-like interface to pass its arguments, so use ldmd2
	DMD=ldmd2 GITVER="v$pkgver" ldc2 -run build.d

	# Build man pages
	./bin/dub --compiler=ldc2 --single scripts/man/gen_man.d

	# Remove redundant rpath
	chrpath -d bin/dub
}

check() {
	bin/dub test --compiler=ldc2
}

package() {
	install -Dvm755 bin/dub -t "$pkgdir"/usr/bin/

	install -Dvm644 scripts/zsh-completion/_dub \
		-t "$pkgdir"/usr/share/zsh/site-functions/

	install -Dvm644 scripts/man/*.1 -t "$pkgdir"/usr/share/man/man1/
	install -Dvm644 LICENSE -t "$pkgdir"/usr/share/licenses/$pkgname/
}

sha512sums="
c8ffa874be206f6e8041635062cd1fa71853d8ccaf9c5eb70353f492b8659c81ab2277e4c19824945f3a527cd4f87b35adc2fa7572b0bf5f80abded63de32ba6  dub-1.40.0.tar.gz
"
