APKBUILD 4.31 KB
Newer Older
Jakub Jirutka's avatar
Jakub Jirutka committed
1
# Contributor: Jakub Jirutka <jakub@jirutka.cz>
2
# Contributor: Milan P. Stanić <mps@arvanta.net>
Jakub Jirutka's avatar
Jakub Jirutka committed
3 4
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=crystal
5
pkgver=0.30.1
6
_pkgcommit=5e6a1b672
7
pkgrel=1
8
_bootver=0.29.0
9
_llvmver=5
Jakub Jirutka's avatar
Jakub Jirutka committed
10 11
pkgdesc="The Crystal Programming Language"
url="https://crystal-lang.org/"
12
arch="x86_64 aarch64"
Jakub Jirutka's avatar
Jakub Jirutka committed
13
license="Apache-2.0"
14
depends="gc-dev libatomic_ops libevent-dev libevent-static gcc gmp-dev pcre-dev"
15
checkdepends="openssl-dev libxml2-dev readline-dev tzdata yaml-dev zlib-dev"
16
makedepends="llvm$_llvmver-dev llvm$_llvmver-static"
Jakub Jirutka's avatar
Jakub Jirutka committed
17 18 19 20 21 22
subpackages="$pkgname-doc
	$pkgname-bash-completion:bashcomp:noarch
	$pkgname-zsh-completion:zshcomp:noarch
	"
source="$pkgname-$pkgver.tar.gz::https://github.com/crystal-lang/$pkgname/archive/$pkgver.tar.gz
	https://dev.alpinelinux.org/archive/crystal/crystal-$_bootver-x86_64-alpine-linux-musl.tar.gz
23
	https://dev.alpinelinux.org/archive/crystal/crystal-$_bootver-aarch64-alpine-linux-musl.tar.gz
24
	disable-specs-using-GB2312-encoding.patch
25
	fix-spec-std-kernel-spec.cr.patch
Jakub Jirutka's avatar
Jakub Jirutka committed
26 27 28
	"
builddir="$srcdir/$pkgname-$pkgver"

29 30 31
_coredir="/usr/lib/$pkgname/core"
_shardsdir="/usr/lib/$pkgname/shards"

Jakub Jirutka's avatar
Jakub Jirutka committed
32
export CRYSTAL_CONFIG_VERSION="$pkgver"
33
export CRYSTAL_CONFIG_BUILD_COMMIT="$_pkgcommit"
Jakub Jirutka's avatar
Jakub Jirutka committed
34 35 36 37 38 39 40 41
export CRYSTAL_CACHE_DIR="$srcdir/.cache"

# Build static crystal binary and upload it to dev.a.o, so it can be used
# for building crystal next time (needed for bootstrapping).
# NOTE: After https://github.com/crystal-lang/crystal/issues/5689 is fixed,
# we can also use prebuilt binary from upstream if needed.
snapshot() {
	local binary="$builddir/.build/crystal"
42
	local tarname="$pkgname-$pkgver-$CTARGET"
Jakub Jirutka's avatar
Jakub Jirutka committed
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

	if [ ! -f "$binary" ] || ! file "$binary" | grep -qw 'statically linked'; then
		msg "Building statically linked crystal..."
		BUILD_STATIC=1 abuild clean deps unpack prepare build
	fi

	cd "$srcdir"

	strip "$builddir"/.build/crystal
	install -D -m 755 "$builddir"/.build/crystal "$tarname"/bin/crystal
	tar -czf "$tarname.tar.gz" "$tarname"

	msg "Uploading $tarname.tar.gz to dev.alpinelinux.org"
	scp "$tarname.tar.gz" dev.alpinelinux.org:/archive/$pkgname/

	APKBUILD="../APKBUILD" abuild undeps
}

prepare() {
	default_prepare
	cd "$builddir"

	cat > Makefile.local <<-EOF
		progress = 1
		threads = ${JOBS:-2}
		verbose = 1
69
		FLAGS = --verbose --target $CTARGET ${BUILD_STATIC:+"--link-flags=-no-pie"}
Jakub Jirutka's avatar
Jakub Jirutka committed
70 71 72 73 74 75 76 77
		LLVM_CONFIG = /usr/lib/llvm$_llvmver/bin/llvm-config
	EOF
}

build() {
	cd "$builddir"

	make crystal \
78
		CRYSTAL_CONFIG_PATH="lib:$_shardsdir:$_coredir" \
79
		PATH="$srcdir/$pkgname-$_bootver-$CBUILD/bin:$PATH" \
80
		LLVM_CONFIG="llvm5-config" \
81
		release=1 \
Jakub Jirutka's avatar
Jakub Jirutka committed
82 83 84 85 86 87
		static=${BUILD_STATIC:-}
}

check() {
	cd "$builddir"

88 89
	make spec LLVM_CONFIG="llvm5-config" PATH=".build:$PATH" \
	SPEC_FLAGS="--no-color --verbose"
Jakub Jirutka's avatar
Jakub Jirutka committed
90 91 92 93 94 95 96 97
}

package() {
	cd "$builddir"

	install -D -m 755 .build/crystal "$pkgdir"/usr/bin/crystal
	install -D -m 644 man/crystal.1 "$pkgdir"/usr/share/man/man1/crystal.1

98 99
	mkdir -p "$pkgdir$_coredir" "$pkgdir$_shardsdir"
	cp -r src/* "$pkgdir$_coredir"/
Jakub Jirutka's avatar
Jakub Jirutka committed
100

101
	cd "$pkgdir$_coredir"
Jakub Jirutka's avatar
Jakub Jirutka committed
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124
	rm ext/sigfault.* llvm/ext/llvm_ext.o
}

bashcomp() {
	pkgdesc="Bash completions for $pkgname"
	depends=""
	install_if="$pkgname=$pkgver-r$pkgrel bash-completion"

	cd "$builddir"
	install -D -m 644 etc/completion.bash \
		"$subpkgdir"/usr/share/bash-completion/completions/$pkgname
}

zshcomp() {
	pkgdesc="ZSH completions for $pkgname"
	depends=""
	install_if="$pkgname=$pkgver-r$pkgrel zsh"

	cd "$builddir"
	install -D -m 644 etc/completion.zsh \
		"$subpkgdir"/usr/share/zsh/site-functions/_$pkgname
}

125
sha512sums="62ddb0dc45385d52d7fdd593f85ec4bef2451aa9a48aabe0115ffe8cfe820e6665b2d51d097339fe931d8599bb6c62c7ddfcaae36a199db0726df4e246af6eab  crystal-0.30.1.tar.gz
126 127
daf684e4d1bbcc92b2fa39cce40f4938e7fb8927349182941b1a2f5542266f1dcaa8401bb52376bd09a9499cccd2d291eaaad8360390efe23bcce90131ebe03d  crystal-0.29.0-x86_64-alpine-linux-musl.tar.gz
0d92e7b50cfc931f70ba805a8ab775802cbe958908e84881c331adf81cbfe33664f11d3a722c0b98b6043f43d0e5a0f58c012145c7440fd34716c1b58972b9df  crystal-0.29.0-aarch64-alpine-linux-musl.tar.gz
128
269976fbc990dde075769e651c9fac6e7e0b39681e55cbd067c6d2a790c58a096bdc9981f62ae69b5217623025ba768daa63bc5316bd8ddd18192d88839aedcb  disable-specs-using-GB2312-encoding.patch
129
ee1d81b40a9b15b2abfecbc61a1ef830700cc5613f9d2626722e8393633ed5d40329ac1fc2813b08b66c689876d3bd8a9f949a22beeda572ea3d4753f58417a8  fix-spec-std-kernel-spec.cr.patch"