# Contributor: Mathias LANG <pro.mathias.lang@gmail.com>
# Maintainer: Celeste <cielesti@protonmail.com>
maintainer="Celeste <cielesti@protonmail.com>"
pkgname=dtools
pkgver=2.111.0
pkgrel=0
pkgdesc="Ancillary tools for the D programming language compiler"
url="https://github.com/dlang/tools"
arch="x86_64"
license="BSL-1.0"
makedepends="chrpath dmd"
source="$pkgname-$pkgver.tar.gz::https://github.com/dlang/tools/archive/v$pkgver.tar.gz"
builddir="$srcdir/tools-$pkgver"
options="!check" # todo

# There are 4 'public' tools in the repository as of v2.098.0
# In addition, there are a few 'build' tools which could be
# useful (and can be trivially added if needed).
#
# Out of those 4 public tools, only 'dman' has heavy dependencies,
# as it rely on building dlang.org (and by extension DMD & co),
# so it is excluded from this package.

build() {
	msg "building rdmd"
	dmd -v -of=dtools-rdmd -L=--build-id rdmd.d

	for tool in DustMite/dustmite ddemangle catdoc detab tolf dget; do
		msg "building $tool"
		./dtools-rdmd -v --compiler=dmd --build-only -of=dtools-"$(basename $tool)" $tool.d
	done
}

package() {
	for tool in rdmd ddemangle catdoc detab tolf dget dustmite; do
		install -Dm755 $pkgname-$tool -t "$pkgdir"/usr/bin
	done
	ln -s dtools-rdmd "$pkgdir"/usr/bin/rdmd
	ln -s dtools-dustmite "$pkgdir"/usr/bin/dustmite
	ln -s dtools-ddemangle "$pkgdir"/usr/bin/ddemangle
	chrpath -d "$pkgdir"/usr/bin/*
}

sha512sums="
0e1c3f206ebef0f0f68843d6dea3ddf8610ae2732c197ab84f5840d0b9498c598123e6ac7fb95edde24ca853d66ac29011eda6fb7b42a8f3ca3f5ae1599c913f  dtools-2.111.0.tar.gz
"
