# Contributor: Jakub Jirutka # Maintainer: Jakub Jirutka pkgname=crystal pkgver=0.27.2 pkgrel=0 _bootver=0.27.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="openssl-dev libxml2-dev readline-dev tzdata yaml-dev zlib-dev" makedepends="llvm$_llvmver-dev 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 disable-specs-using-GB2312-encoding.patch fix-spec-std-kernel-spec.cr.patch fix-spec-std-socket-tcp_server_spec.cr.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="dcb5948f373d4a7b17e6bdd45697a43e86ec7eb38bdafaade982df9adacbc5a24f2b08f327e41b853bb8f6ec8272411d14defee4e510c430c5dd1370afca42ae crystal-0.27.2.tar.gz 0519f6c68de8087a618ff05b88f4dcc3190e63997d810d9eaaa8d6d14fca523a158e3bb4d36a56862178643bae46016ae93e6b6041deeb547efe1163e9dd03f5 crystal-0.27.0-x86_64-alpine-linux-musl.tar.gz e5614293ac4d8fe35f0e8b9c4bce363380504b9afb7d2a015bf057d39a9bdc4c4b0c403808ccb840f7588054ab8cf4148a701e66780a202853715462a1c06732 crystal-0.27.0-aarch64-alpine-linux-musl.tar.gz 269976fbc990dde075769e651c9fac6e7e0b39681e55cbd067c6d2a790c58a096bdc9981f62ae69b5217623025ba768daa63bc5316bd8ddd18192d88839aedcb disable-specs-using-GB2312-encoding.patch ee1d81b40a9b15b2abfecbc61a1ef830700cc5613f9d2626722e8393633ed5d40329ac1fc2813b08b66c689876d3bd8a9f949a22beeda572ea3d4753f58417a8 fix-spec-std-kernel-spec.cr.patch 560da65be712983e036fcc614cb191647a4dbd76bacae97e0c2d5cdc3016de23daa44bd63f4fb509c5bd9e58419e63db7403faa8cd9d0b7af4ac2477efb9ff3b fix-spec-std-socket-tcp_server_spec.cr.patch"