aboutsummaryrefslogtreecommitdiffstats
path: root/testing/ldc/APKBUILD
blob: 71e5ed553ad250db11da48b820adb4c22000cc2b (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
97
98
99
100
101
102
103
104
105
106
107
# Contributor: Mathias LANG <pro.mathias.lang@gmail.com>
# Maintainer: Mathias LANG <pro.mathias.lang@gmail.com>
pkgname=ldc
pkgver=1.8.0
pkgrel=0
pkgdesc="The LLVM-based D Compiler"
url="https://github.com/ldc-developers/ldc"
# Bootstrapping was done with an upstream-provided package,
# with only x86_64 available
# Once we can use GDC for bootstrapping, this can be "all"
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"
makedepends="chrpath cmake llvm5-libs libexecinfo-static"
# A user might want to install the '-runtime' subpackage when they have
# a dynamically-linked D program.
subpackages="$pkgname-runtime $pkgname-doc $pkgname-static"
provides="dlang-compiler"
source="https://github.com/ldc-developers/ldc/releases/download/v$pkgver/ldc2-$pkgver-alpine-linux-x86_64.tar.xz
		ldc2.package.conf"
builddir="$srcdir/"

build() {
	rootdir="$srcdir/ldc2-$pkgver-alpine-linux-x86_64/"

	# Unfortunately the upstream-provided version has the builder's /home/ in its rpath - strip it
	chrpath -d "$rootdir/bin/ldc2"
	chrpath -d "$rootdir/bin/ldmd2"
	# This exe is not installed, just used in build, but do it for completeness
	chrpath -d "$rootdir/bin/ldc-build-runtime"

	# Now build the runtime - the compiler itself is already built by upstream
	"$rootdir"/bin/ldc-build-runtime --buildDir="$builddir/ldc-runtime-build/"

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

check() {
	rootdir="$srcdir/ldc2-$pkgver-alpine-linux-x86_64/"
	libroot="$builddir/ldc-runtime-build/lib/"

	echo 'import std.stdio; void main () { try throw new Exception(null); catch (Exception) writeln("Hello World!"); }' > hello_world.d
	if [ "$($rootdir/bin/ldmd2 -conf='' -I$rootdir/import/ldc -I$rootdir/import/ -L-L$libroot -defaultlib=phobos2-ldc,druntime-ldc -L-lexecinfo -L-rpath=$libroot -run hello_world.d)" != "Hello World!" ]; then
		return 1
	fi
	:
}

package() {
	depends="$pkgname-runtime $pkgname-static"
	rootdir="$srcdir/ldc2-$pkgver-alpine-linux-x86_64/"

	install -s -D "$rootdir/bin/ldc2"  "$pkgdir/usr/bin/ldc2"
	install -s -D "$rootdir/bin/ldmd2" "$pkgdir/usr/bin/ldmd2"

	install -D "$srcdir/ldc2.package.conf" "$pkgdir/etc/ldc2.conf"

	install -D "$rootdir/LICENSE" "$pkgdir/usr/share/licenses/$pkgname/LICENSE"

	# Install the import files
	for impfile in $(find "$rootdir/import" -name "*.d*");
	do
		target="${impfile##*import/}"
		install -D "$impfile" "$pkgdir/usr/include/dlang/$pkgname-$pkgver/$target"
	done

	# Install the static runtime libraries
	for libn in "libdruntime-ldc" "libdruntime-ldc-debug" "libphobos2-ldc" "libphobos2-ldc-debug";
	do
		install -D "$builddir/ldc-runtime-build/lib/$libn.a" "$pkgdir/usr/lib/$libn.a"
	done

	# Install the shared runtime libraries
	for libn in "libdruntime" "libphobos2";
	do
		install -D "$builddir/ldc-runtime-build/lib/$libn-ldc-shared.so.2.0.78" "$pkgdir/usr/lib/$libn-ldc-shared.so.2.0.78"
	done
}

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.2.0.78" "$subpkgdir/usr/lib/$libn-ldc-shared.so.2.0.78"
		ln -s "$libn-ldc-shared.so.2.0.78" "$pkgdir/usr/lib/$libn-ldc-shared.so.78"
		ln -s "$libn-ldc-shared.so.2.0.78" "$pkgdir/usr/lib/$libn-ldc-shared.so"
	done

	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="3a870c9e7e9500d4e2a47e53d10cb10641319223200e3730abf9b6debf1c261cef11bac0b797ee2aa66c63c950461326273e0c14685b6d641155de307997e1af  ldc2-1.8.0-alpine-linux-x86_64.tar.xz
0fd1613ffdd52db1f486ad15bc5f2df2f2f1b94bddf12d67a38897f73cd83d5d222bb184dd88df1058be9f9d31fdb6c8d6850d6ce672d25e4a0cbbf579d248a1  ldc2.package.conf"