aboutsummaryrefslogtreecommitdiffstats
path: root/testing/ldc/APKBUILD
blob: ea4e700519c086b8170bf9482cae3c676434d07b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# Contributor: Mathias LANG <pro.mathias.lang@gmail.com>
# Maintainer: Mathias LANG <pro.mathias.lang@gmail.com>
pkgname=ldc
pkgver=1.20.0
pkgrel=1
pkgdesc="The LLVM-based D Compiler"
url="https://github.com/ldc-developers/ldc"
# LDC does not support host compiling on most of the architecture Alpine supports
arch="x86_64"
license="BSD-3-Clause AND BSL-1.0 AND ( Artistic-1.0 OR GPL-2.0-or-later ) AND NCSA AND MIT"
depends="libexecinfo tzdata"
makedepends="chrpath cmake curl-dev diffutils gdmd llvm9-dev llvm9-static libedit-dev libexecinfo-static zlib-dev"
checkdepends="bash gdb grep llvm9-test-utils"
# A user might want to install the '-runtime' subpackage when they have
# a dynamically-linked D program.
subpackages="$pkgname-runtime $pkgname-static"
source="https://github.com/ldc-developers/ldc/releases/download/v$pkgver/ldc-$pkgver-src.tar.gz
		01-conf.patch
		"
builddir="$srcdir/ldc-$pkgver-src/"

build() {
	# First, build LDC using GDC
	mkdir -p "$builddir/stage1"
	if [ "$CBUILD" != "$CHOST" ]; then
		CMAKE_CROSSOPTS="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
	fi
	cmake \
		-DCMAKE_CXX_FLAGS="$CXXFLAGS" \
		-DCMAKE_C_FLAGS="$CFLAGS" \
		-DD_COMPILER='gdmd' \
		$CMAKE_CROSSOPTS -S "$builddir" -B "$builddir/stage1"
	make -C "$builddir/stage1"

	# Then, self-build
	if [ "$CBUILD" != "$CHOST" ]; then
		CMAKE_CROSSOPTS="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
	fi
	cmake \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DBUILD_SHARED_LIBS=True \
		-DCMAKE_BUILD_TYPE=None \
		-DCMAKE_CXX_FLAGS="$CXXFLAGS" \
		-DCMAKE_C_FLAGS="$CFLAGS" \
		-DD_COMPILER="$builddir/stage1/bin/ldmd2" \
		$CMAKE_CROSSOPTS "$builddir"
	make

	# CMake added the rpaths to the shared libs - strip them
	chrpath -d "$builddir"/lib/*.so*
}

check() {
	# Note: The testsuite does not parallelize well, as the 'clean' target get run in parallel.
	# Hence '-j${JOBS}' was left out on purpose
	#
	# - dmd-testsuite takes too long to run and has more to do with language checks
	#	which are less relevant to us than platform integration tests
	# - lit-test disabled because 'TEST 'LDC :: debuginfo/print_gdb.d' FAILED'
	#	Something to do with TLS variables not being printable in GDB
	# - 'druntime-test-shared' fails, probably because it is using 'Object.factory'
	# - 'druntime-test-stdcpp' fails for an unknown reason and is temporarily disabled
	# - 'druntime-test-exceptions' fails for an unknown reason and is temporarily disabled
	ctest --output-on-failure -E "dmd-testsuite|lit-tests|druntime-test-exceptions|druntime-test-shared|druntime-test-stdcpp"
}

package() {
	depends="$pkgname-static=$pkgver-r$pkgrel"
	make DESTDIR="$pkgdir" install
}

runtime() {
	depends="libexecinfo-dev"
	pkgdesc="Dynamic runtime library for D code compiled with $pkgname-$pkgver"

	mkdir -p "$subpkgdir/usr/lib/"
	for libn in "libdruntime" "libphobos2";
	do
		mv "$pkgdir"/usr/lib/$libn-ldc-shared.so* "$subpkgdir/usr/lib/"
	done
	mv "$pkgdir"/usr/lib/libldc-jit.so* "$subpkgdir/usr/lib"

	mv "$pkgdir"/usr/lib/*.so* "$subpkgdir/usr/lib/"
}

static() {
	depends="libexecinfo-static"
	pkgdesc="$pkgdesc (static library)"

	mkdir -p "$subpkgdir/usr/lib/"
	mv "$pkgdir"/usr/lib/*.a "$subpkgdir/usr/lib/"
}

sha512sums="6a94400a9f28bc5fe0d12d5ab5aa188eb84d929c61ee79f3d87e9719f4e72cc1b658c4290d30e038ee6f741ca55f81007965102b0c591d75234aa4ea57d6f21f  ldc-1.20.0-src.tar.gz
eb86e4be0ecf72aaabbd5608c8056bb9cede035895e766330b6d14f14c06dc513fcecc1b6e56ab6fc9fc26c220a689cc8b1394a30a319189c414f1e067c1d983  01-conf.patch"