aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeod24 <pro.mathias.lang@gmail.com>2019-08-15 05:41:14 +0900
committerRasmus Thomsen <oss@cogitri.dev>2019-10-16 22:42:25 +0200
commit92cc8faac08a3f9a0089a057d419f3c6ba4c93de (patch)
tree1751a5df792352a6b1f4745fc82b534f2995e1a5
parenta3b113a21dd2d77be061051be9228ad73c0fb7a7 (diff)
downloadaports-92cc8faac08a3f9a0089a057d419f3c6ba4c93de.tar.bz2
aports-92cc8faac08a3f9a0089a057d419f3c6ba4c93de.tar.xz
testing/ldc: new aport
This add a package to support the D Programming Language. Currently, one has to jump through hoops in order to use D on Alpine. This packages installs the official (and only) LDC build that came with an Alpine build, LDC-1.8.0. While it is an old version of the compiler, 2.078.3, it can be used to bootstrap other compiler versions.
-rw-r--r--testing/ldc/APKBUILD107
-rw-r--r--testing/ldc/ldc2.package.conf24
2 files changed, 131 insertions, 0 deletions
diff --git a/testing/ldc/APKBUILD b/testing/ldc/APKBUILD
new file mode 100644
index 0000000000..71e5ed553a
--- /dev/null
+++ b/testing/ldc/APKBUILD
@@ -0,0 +1,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"
diff --git a/testing/ldc/ldc2.package.conf b/testing/ldc/ldc2.package.conf
new file mode 100644
index 0000000000..b7eb7febf1
--- /dev/null
+++ b/testing/ldc/ldc2.package.conf
@@ -0,0 +1,24 @@
+// See comments in driver/config.d in ldc source tree for grammar description of
+// this config file.
+
+// The default group is required
+default:
+{
+ // default switches injected before all explicit command-line switches
+ switches = [
+ // ldc2 is installed in $pkgdir/usr/bin/ldc2
+ // Imports are in $pkgdir/usr/include/dlang/ldc-1.8.0/
+ "-I%%ldcbinarypath%%/../include/dlang/ldc-1.8.0/ldc/",
+ "-I%%ldcbinarypath%%/../include/dlang/ldc-1.8.0/",
+ "-defaultlib=phobos2-ldc,druntime-ldc"
+ ];
+ // default switches appended after all explicit command-line switches
+ post-switches = [
+ // libs are installed to $pkgdir/usr/lib/
+ // `libexecinfo` includes `backtrace`, which is used by druntime,
+ // and is part of glibc
+ "-L-L%%ldcbinarypath%%/../lib",
+ "-L--no-warn-search-mismatch",
+ "-L-lexecinfo"
+ ];
+};