From b0babf6b46c497b35b83598bd6bb238d6cc8cf9e Mon Sep 17 00:00:00 2001 From: Julien Elbaz Date: Sun, 22 Oct 2023 08:07:02 +0200 Subject: [PATCH] +crystal-lang.org (#3669) * add(crystal-lang) * move to bootstrap this always hurts * oops * linux needs explicit -z * linux not detecting the compiler well * Only shim build * needs ncurses * shim needs link flags for eval? * need link flags for test * maybe what eval needs is --static * the docs are wrong * this should do it, i think * perhaps static linkage * punt --------- Co-authored-by: Jacob Heider Co-authored-by: Jacob Heider --- projects/crystal-lang.org/package.yml | 82 ++++++++++++++++++++ projects/crystal-lang.org/shards/package.yml | 55 +++++++++++++ projects/crystal-lang.org/shim | 9 +++ 3 files changed, 146 insertions(+) create mode 100644 projects/crystal-lang.org/package.yml create mode 100644 projects/crystal-lang.org/shards/package.yml create mode 100755 projects/crystal-lang.org/shim diff --git a/projects/crystal-lang.org/package.yml b/projects/crystal-lang.org/package.yml new file mode 100644 index 00000000..39e664c2 --- /dev/null +++ b/projects/crystal-lang.org/package.yml @@ -0,0 +1,82 @@ +distributable: + url: https://github.com/crystal-lang/crystal/archive/refs/tags/{{ version }}.tar.gz + strip-components: 1 + +versions: + github: crystal-lang/crystal + +# Crystal is needed to build itself… +# So we cannot build it from source. +warnings: + - vendored + +platforms: + - darwin + - linux/x86-64 + +companions: + crystal-lang.org/shards: '*' + +dependencies: + hboehm.info/gc: ^8 + gnu.org/gmp: ^6 + libevent.org: ^2 + pyyaml.org/libyaml: ^0 + llvm.org: <17 + openssl.org: ^1.1 + pcre.org/v2: ^10 + freedesktop.org/pkg-config: ^0 + sourceware.org/libffi: ^3 + invisible-island.net/ncurses: ^6 + +runtime: + env: + CRYSTAL_PATH: ${{prefix}}/lib:$CRYSTAL_PATH + CRYSTAL_LIBRARY_PATH: $LD_LIBRARY_PATH + +build: + dependencies: + curl.se: '*' + gnu.org/make: '*' + script: + - run: | + curl -Lf "https://github.com/crystal-lang/crystal/releases/download/{{version}}/crystal-{{version}}-1-$PLATFORM.tar.gz" | \ + tar --strip-components=1 -zxf - + working-directory: .bootstrap + - mkdir -p .build + - make deps + - make crystal $ARGS + - mkdir -p "{{prefix}}/bin" + - cp .build/crystal "{{prefix}}/bin/crystal.bin" + - cp props/shim "{{prefix}}/bin/crystal" + - cp -a src "{{prefix}}/lib" + env: + CRYSTAL_LIBRARY_PATH: $LD_LIBRARY_PATH + PATH: $SRCROOT/.bootstrap/bin:$PATH + darwin: { PLATFORM: darwin-universal } + linux/x86-64: { PLATFORM: linux-x86_64 } + LDFLAGS: -Wl,-rpath,{{pkgx.prefix}} + ARGS: + - release=true + - FLAGS=--no-debug + - interpreter=true + - CRYSTAL_CONFIG_PATH=../lib + linux: + CC: clang + CXX: clang++ + LD: clang + +provides: + - bin/crystal + +test: + fixture: puts {{Crystal::VERSION}} + env: + CRYSTAL_LINK_FLAGS: -Wl,-rpath,{{pkgx.prefix}} + script: + - cp $FIXTURE test.cr + - crystal build -o test test.cr + - test "$(./test)" = "{{version}}" + # FIXME: this should work, but because it compiles with LLVM, it needs the + # @rpath set somehow. + # - test "$(crystal eval 'puts {{Crystal::VERSION}}')" = "{{version}}" diff --git a/projects/crystal-lang.org/shards/package.yml b/projects/crystal-lang.org/shards/package.yml new file mode 100644 index 00000000..b9287d21 --- /dev/null +++ b/projects/crystal-lang.org/shards/package.yml @@ -0,0 +1,55 @@ +distributable: + url: https://github.com/crystal-lang/shards/archive/refs/tags/v{{ version }}.tar.gz + strip-components: 1 + +versions: + github: crystal-lang/shards + +platforms: + - darwin + - linux/x86-64 + +runtime: + env: + CRYSTAL_PATH: ${{prefix}}/lib:$CRYSTAL_PATH + +dependencies: + hboehm.info/gc: ^8 + pyyaml.org/libyaml: ^0 + crystal-lang.org: '*' + +build: + dependencies: + curl.se: '*' + script: + - run: | + curl -L https://github.com/crystal-lang/crystal-molinillo/archive/refs/tags/v0.2.0.tar.gz | \ + tar --strip-components=2 -zxf - + mkdir -p "{{prefix}}/lib" + cp -a molinillo molinillo.cr "{{prefix}}/lib" + working-directory: .molinillo + - run: | + sed -i.bak \ + -e 's/MOLINILLO_VERSION = .*$/MOLINILLO_VERSION = 0.2.0/' \ + Makefile + rm Makefile.bak + - make $ARGS bin/shards + - mkdir -p "{{prefix}}/bin" + - install bin/shards "{{prefix}}/bin" + env: + CRYSTAL_LINK_FLAGS: -Wl,-rpath,{{pkgx.prefix}} + CRYSTAL_PATH: ${{prefix}}/lib:$CRYSTAL_PATH + ARGS: + - release=true + - FLAGS=--no-debug + - CRYSTAL={{deps.crystal-lang.org.prefix}}/bin/crystal + - SHARDS=false + +provides: + - bin/shards + +test: + script: | + out=($(shards --version)) + version=${out[1]} + test $version = {{version}} diff --git a/projects/crystal-lang.org/shim b/projects/crystal-lang.org/shim new file mode 100755 index 00000000..3deba49f --- /dev/null +++ b/projects/crystal-lang.org/shim @@ -0,0 +1,9 @@ +#!/bin/sh + +cmd="$1" +shift + +case "$cmd" in + build) crystal.bin "$cmd" --link-flags "${CRYSTAL_LINK_FLAGS:-}" "$@";; + *) crystal.bin "$cmd" "$@";; +esac