aboutsummaryrefslogtreecommitdiffstats
path: root/community/crystal/APKBUILD
blob: aee1243a7c4474bf50685706dcf4bd4fe393c0ec (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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=crystal
pkgver=0.26.1
pkgrel=0
_bootver=0.25.0
_llvmver=5
pkgdesc="The Crystal Programming Language"
url="https://crystal-lang.org/"
arch="x86_64 aarch64"
license="Apache-2.0"
depends="gc-dev libatomic_ops libevent-dev gcc gmp-dev pcre-dev"
checkdepends="libressl-dev libxml2-dev paxmark readline-dev tzdata yaml-dev zlib-dev"
makedepends="llvm$_llvmver-dev ${BUILD_STATIC:+"llvm$_llvmver-static"}"
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
	https://dev.alpinelinux.org/archive/crystal/crystal-$_bootver-aarch64-alpine-linux-musl.tar.gz
	paxmark.patch
	disable-specs-using-GB2312-encoding.patch
	fix-spec-time-location.patch
	libressl.patch
	tests-libressl.patch
	"
builddir="$srcdir/$pkgname-$pkgver"

_coredir="/usr/lib/$pkgname/core"
_shardsdir="/usr/lib/$pkgname/shards"

export CRYSTAL_CONFIG_VERSION="$pkgver"
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"
	local tarname="$pkgname-$pkgver-$CTARGET"

	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
		FLAGS = --verbose --target $CTARGET ${BUILD_STATIC:+"--link-flags=-no-pie"}
		LLVM_CONFIG = /usr/lib/llvm$_llvmver/bin/llvm-config
	EOF
}

build() {
	cd "$builddir"

	make crystal \
		CRYSTAL_CONFIG_PATH="lib:$_shardsdir:$_coredir" \
		PATH="$srcdir/$pkgname-$_bootver-$CBUILD/bin:$PATH" \
		release=1 \
		static=${BUILD_STATIC:-}
}

check() {
	cd "$builddir"

	make spec PATH=".build:$PATH" SPEC_FLAGS="--no-color --verbose"
}

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

	mkdir -p "$pkgdir$_coredir" "$pkgdir$_shardsdir"
	cp -r src/* "$pkgdir$_coredir"/

	cd "$pkgdir$_coredir"
	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
}

sha512sums="5e020b0f262f9bedaaae60010f669d7987a77d3416bf0dd057e29eb11adbe8fceb1c4f55a822e623d32e302a01ccc99218d2c3fe474d4ce0dde4312c196ccfa6  crystal-0.26.1.tar.gz
b443520d994355f849e18d5432dc136f6e403eb77a432a53e3d38e5a050a7547632bbe7a99a3a4c193f91fdf2240a1629acd516291d16c3bbfa14a9ec47435b2  crystal-0.25.0-x86_64-alpine-linux-musl.tar.gz
43b058e94f990e853f2ade5bf234aaea4547176172beff8ed372c5158ec8bb59c3925e0bb3bf7c2e4024193bcd48652faebba3ce08c5f0e25425ca073a66adb0  crystal-0.25.0-aarch64-alpine-linux-musl.tar.gz
dec4ed7abfd215eec825bed97b1e40bf3aa8bd959a4ec7153ea1bc51d409d892ebec19ddb0372e3a543e74c7018aca0c1f3cf956fa1d95efb946c8c3417c8749  paxmark.patch
269976fbc990dde075769e651c9fac6e7e0b39681e55cbd067c6d2a790c58a096bdc9981f62ae69b5217623025ba768daa63bc5316bd8ddd18192d88839aedcb  disable-specs-using-GB2312-encoding.patch
518f06dd191e43e4052c0f8c4963d31dfc7ed3b414d1bb2e7a82265af13853f85380b5507ef3c5a5a25f6091d7173d5322f379e354666eec4165264dd502e70b  fix-spec-time-location.patch
31fd94f07edb83eb6ff43dd20f99a52e3c28dc0bf67f7e0b5c473c40d455febfbd0cdf9fe1fe599dbf080fd4c05a2a2d9ad8745f9effc8dfb565e19fa0e49509  libressl.patch
35764190eb4df353057c771935c6b6588cddb3a164e624e3a07371c78e49f4dc938fd1296fdb048c08c482b5066b56f6d0b5eab5f48fdba80b01d2cf6e0ad24e  tests-libressl.patch"