From cd2389d019f6faf0154fcdfdbb36854ff6bc1699 Mon Sep 17 00:00:00 2001 From: Pim Snel Date: Mon, 5 Apr 2021 16:20:44 +0200 Subject: [PATCH] srcpkgs/crystal: New package: crystal-1.0.0 --- srcpkgs/crystal/template | 123 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 123 insertions(+) create mode 100644 srcpkgs/crystal/template diff --git a/srcpkgs/crystal/template b/srcpkgs/crystal/template new file mode 100644 index 000000000000..e0f7d50e55b0 --- /dev/null +++ b/srcpkgs/crystal/template @@ -0,0 +1,123 @@ +# Template file for 'crystal' +pkgname=crystal +version=1.0.0 +revision=1 +archs="x86_64* i686*" +_shardsversion=0.14.1 +_molinilloversion=0.1.0 +_bootstrapversion=1.0.0 +_bootstraprevision=1 +hostmakedepends="which tar llvm11 pkg-config" +makedepends="gc-devel libatomic_ops pcre-devel libevent-devel libyaml-devel libxml2-devel" +depends="gc-devel libatomic_ops pcre-devel libevent-devel libyaml-devel libxml2-devel gmp-devel openssl-devel llvm11 gcc pkg-config" +checkdepends="readline-devel libyaml-devel gmp-devel openssl-devel git" +short_desc="Crystal Programming Language" +maintainer="lvmbdv " +license="Apache-2.0" +homepage="https://crystal-lang.org/" +distfiles=" + https://github.com/crystal-lang/crystal/archive/${version}.tar.gz + https://github.com/crystal-lang/shards/archive/v${_shardsversion}.tar.gz + https://github.com/crystal-lang/crystal-molinillo/archive/v${_molinilloversion}.tar.gz" +checksum="6b85c9139a891732c1f10638030635ff9dbe4e6818cad81a5dbd72db40913019 + 040b080acb4d4d44bfe07897219fdcb7525f783e253d8878d8381bf78f13f328 + 1ecc7a8bf52a3bfdc0134d4c58f1155ef204a22a3fed151ac2d4ba6a9e9e0a15" +nocross="FIXME: someone needs to sort out the llvm --cxxflags for cross building" +_crystalflags="--release --no-debug --progress" + +build_options="binary_bootstrap" +build_options_default="binary_bootstrap" +desc_option_binary_bootstrap="Bootstrap using precompiled binaries" + +if [ "$build_option_binary_bootstrap" ]; then + case "$XBPS_MACHINE" in + x86_64*) + distfiles+=" https://github.com/crystal-lang/crystal/releases/download/${_bootstrapversion}/crystal-${_bootstrapversion}-${_bootstraprevision}-linux-x86_64.tar.gz" + checksum+=" 00211ca77758e99210ec40b8c5517b086d2ff9909e089400f6d847a95e5689a4" + ;; + i686) + distfiles+=" https://github.com/crystal-lang/crystal/releases/download/${_bootstrapversion}/crystal-${_bootstrapversion}-${_bootstraprevision}-linux-i686.tar.gz" + checksum+=" 90ed246a21a94643153df455e7f6c1d5c102e062f1de1353e9504691b9230e70" + ;; + *) + broken="cannot be built on $XBPS_MACHINE" + ;; + esac +else + hostmakedepends+=" crystal" +fi + +do_extract() { + rm -Rf ${wrksrc}/shards/lib/molinillo + mkdir -p ${wrksrc}/{shards,shards/lib,shards/lib/molinillo,molinillo,$(vopt_if binary_bootstrap bootstrap)} + tar xfz ${XBPS_SRCDISTDIR}/${pkgname}-${version}/${version}.tar.gz --strip-components=1 -C ${wrksrc} + tar xfz ${XBPS_SRCDISTDIR}/${pkgname}-${version}/v${_shardsversion}.tar.gz --strip-components=1 -C ${wrksrc}/shards + tar xfz ${XBPS_SRCDISTDIR}/${pkgname}-${version}/v${_molinilloversion}.tar.gz --strip-components=1 -C ${wrksrc}/molinillo + + mv -f ${wrksrc}/molinillo/src/* ${wrksrc}/shards/lib/molinillo + if [ "$build_option_binary_bootstrap" ]; then + case "$XBPS_MACHINE" in + x86_64-musl) + tar xf ${XBPS_SRCDISTDIR}/${pkgname}-${version}/crystal-${_bootstrapversion}-${_bootstraprevision}-linux-x86_64.tar.gz \ + --strip-components=1 --exclude='lib/crystal/lib/libgc.a' -C ${wrksrc}/bootstrap + ;; + *) + tar xf ${XBPS_SRCDISTDIR}/${pkgname}-${version}/crystal-${_bootstrapversion}-${_bootstraprevision}-linux-${XBPS_TARGET_MACHINE}.tar.gz \ + --strip-components=1 -C ${wrksrc}/bootstrap + ;; + esac + fi +} + +do_build() { + if [ -z ${disable_parallel_build} ] && [ ${XBPS_MAKEJOBS} ]; then + _crystalflags="${_crystalflags} --threads ${makejobs:2:4}" + fi + make ${makejobs} release=1 FLAGS="${_crystalflags}" \ + CRYSTAL_CONFIG_PATH="lib:/usr/lib/crystal" \ + CRYSTAL_CONFIG_VERSION="${version}" \ + CRYSTAL_CACHE_DIR="/tmp/crystal" \ + $(vopt_if binary_bootstrap PATH="${wrksrc}/bootstrap/bin:$PATH") + make ${makejobs} docs CRYSTAL_CACHE_DIR="/tmp/crystal" + + cd shards + ${wrksrc}/bin/crystal build ${_crystalflags} -o bin/shards src/shards.cr +} + +do_check() { + export PATH="${wrksrc}/.build:${wrksrc}/bin:/usr/bin:/bin" + #make ${makejobs} spec \ + # CRYSTAL_CONFIG_VERSION="${version}" \ + # CRYSTAL_CACHE_DIR="/tmp/crystal" + + ./bin/crystal build --single-module \ + --exclude-warnings spec/std \ + --exclude-warnings spec/compiler \ + -o .build/std_spec spec/std_spec.cr + + cd shards + git config --global user.email "void@blackhole.none" + git config --global user.name "Void Linux" + ../bin/crystal spec ./spec/unit/ + ../bin/crystal spec ./spec/integration/ + #make test +} + +do_install() { + vmkdir /usr/bin + vmkdir /usr/lib/crystal + vmkdir /usr/share/doc/crystal + vmkdir /usr/share/doc/crystal/api + vmkdir /usr/share/licenses/shards + + vinstall etc/completion.bash 644 \ + usr/share/bash-completion/completions crystal + vinstall etc/completion.zsh 644 usr/share/zsh/site-functions _crystal + vcopy samples /usr/share/doc/crystal + vcopy docs/* /usr/share/doc/crystal/api + vcopy src/* /usr/lib/crystal + vbin .build/crystal crystal + vman man/crystal.1 + vbin shards/bin/shards + cp shards/LICENSE ${DESTDIR}/usr/share/licenses/shards +}