/
.cirrus.yml
158 lines (143 loc) · 6.65 KB
/
.cirrus.yml
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
# We use Cirrus CI to create release builds for a handful of platforms.
#
# This task builds the Savi compiler, and then packages it all up in a tar.gz
# file to be attached to the release in GitHub, for easy download and use.
task:
environment:
GITHUB_API_TOKEN: ENCRYPTED[5f9b960dd53fb09b34bcb26f7f8a926071f0177e0ec814e7d122db0e2184d3e913ec78d5748e27664c0fef66fde950fe]
CC: clang
CXX: clang++
matrix:
- name: x86_64-unknown-linux-gnu
container:
image: ubuntu:20.04
environment:
TRIPLE: x86_64-unknown-linux-gnu
DEPS_INSTALL: "\
apt-get update && \
apt-get install -y --no-install-recommends \
apt-transport-https ca-certificates curl clang make \
libgc-dev libevent-dev libpcre3-dev llvm-10-dev && \
curl -fsSL https://crystal-lang.org/install.sh | bash"
# Without this next environment var, apt-get will try to ask us
# interactive questions, to which we will be unable to respond...
DEBIAN_FRONTEND: noninteractive
- name: x86_64-unknown-linux-musl
environment:
TRIPLE: x86_64-unknown-linux-musl
DEPS_INSTALL: "\
apk add --no-cache --update \
bash curl alpine-sdk coreutils \
gcc g++ clang make linux-headers llvm13-dev zlib-static \
pcre-dev libevent-static gc-dev crystal shards libexecinfo-dev"
# For some reason clang doesn't like it if we omit the "alpine" vendor
# in the triple, where we'd otherwise use `x86_64-unknown-linux-musl`.
MAKE_EXTRA_ARGS: CLANG_TARGET_PLATFORM=x86_64-alpine-linux-musl
container:
image: alpine:edge # TODO: use alpine:3.16 when released
- name: arm64-unknown-linux-musl
environment:
TRIPLE: arm64-unknown-linux-musl
DEPS_INSTALL: "\
apk add --no-cache --update \
bash curl alpine-sdk coreutils \
gcc g++ clang make linux-headers llvm13-dev zlib-static \
pcre-dev libevent-static gc-dev crystal shards libexecinfo-dev"
# For some reason clang doesn't like it if we omit the "alpine" vendor
# in the triple, where we'd otherwise use `arm64-unknown-linux-musl`.
# We also need to use `aarch64` instead of `arm64` here...
MAKE_EXTRA_ARGS: CLANG_TARGET_PLATFORM=aarch64-alpine-linux-musl
arm_container:
image: alpine:edge # TODO: use alpine:3.16 when released
# # TODO: Enable FreeBSD after getting it working:
# - name: x86_64-unknown-freebsd
# environment:
# TRIPLE: x86_64-unknown-freebsd
# DEPS_INSTALL: "
# echo 'FreeBSD:{url:"pkg+http://pkg.FreeBSD.org/${ABI}/latest"}' \
# > /usr/local/etc/pkg/repos/FreeBSD.conf && \
# pkg update && \
# pkg install -y libunwind bash curl llvm-devel crystal shards && \
# ln -s /usr/local/bin/llvm-config-devel /usr/bin/llvm-config"
# freebsd_instance:
# image: freebsd-13-0-release-amd64
- name: x86_64-apple-macosx
environment:
TRIPLE: x86_64-apple-macosx
DEPS_INSTALL: brew update --preinstall && brew install libiconv crystal && brew cleanup
# Set up the SDKROOT path specific to the present XCode version.
SDKROOT: /Applications/Xcode-12.5.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk
HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK: "1" # optimizes brew install
macos_instance:
image: big-sur-xcode-12.5
# Caching some homebrew directories helps save some of the otherwise huge
# amount of time that it takes to update brew from the CI base image.
brew_cache:
folder: "$HOME/Library/Caches/Homebrew"
brew_usr_local_cache:
folder: "/usr/local/Homebrew"
- name: arm64-apple-macosx
environment:
TRIPLE: arm64-apple-macosx
IS_CROSS_COMPILE: "1"
# Download arm64 versions of the libraries needed by Crystal runtime.
DEPS_INSTALL: "
brew update --preinstall && brew install crystal && brew cleanup && \
mkdir /tmp/arm64 && \
brew fetch --bottle-tag=arm64_big_sur libgc && \
brew fetch --bottle-tag=arm64_big_sur libevent && \
brew fetch --bottle-tag=arm64_big_sur pcre && \
tar -xvf `brew --cache --bottle-tag=arm64_big_sur libgc` -C /tmp/arm64 --strip-components=2 && \
tar -xvf `brew --cache --bottle-tag=arm64_big_sur libevent` -C /tmp/arm64 --strip-components=2 && \
tar -xvf `brew --cache --bottle-tag=arm64_big_sur pcre` -C /tmp/arm64 --strip-components=2 && \
ls /tmp/arm64/lib"
# Tell make to use those arm64 versions we downloaded above.
MAKE_EXTRA_ARGS: " \
TARGET_PLATFORM=arm64-apple-macosx \
LLVM_STATIC_PLATFORM=x86_64-apple-macosx \
LIB_GC=/tmp/arm64/lib/libgc.a \
LIB_EVENT=/tmp/arm64/lib/libevent.a \
LIB_PCRE=/tmp/arm64/lib/libpcre.a"
# Set up the SDKROOT path specific to the present XCode version.
SDKROOT: /Applications/Xcode-12.5.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk
HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK: "1" # optimizes brew install
macos_instance:
image: big-sur-xcode-12.5
# Caching some homebrew directories helps save some of the otherwise huge
# amount of time that it takes to update brew from the CI base image.
brew_cache:
folder: "$HOME/Library/Caches/Homebrew"
brew_usr_local_cache:
folder: "/usr/local/Homebrew"
os_info_script:
- uname
- uname -m
- uname -a
deps_script:
- echo "${DEPS_INSTALL}"
- sh -c "${DEPS_INSTALL}"
build_script:
- mkdir -p out/bin
- make build/savi-release SAVI_VERSION=${CIRRUS_TAG:-unknown} ${MAKE_EXTRA_ARGS}
- mv build/savi-release out/bin/savi
copy_core_script:
- mkdir -p out
- cp -r core out/core
copy_runtime_script:
- mkdir -p out/lib
- cp -r lib/libsavi_runtime out/lib/libsavi_runtime
smoke_test_unless_cross_compile_script:
- test -n "${IS_CROSS_COMPILE}" || out/bin/savi eval --backtrace --print-perf 'env.out.print("No smoke!")'
archive_script:
- tar -czvf /tmp/savi.tar.gz -C out .
publish_if_release_script:
- >-
sh -c '
test -z "${CIRRUS_RELEASE}" || \
curl -v --fail -X POST \
-H "Authorization: token ${GITHUB_API_TOKEN}" \
-H "Accept: application/vnd.github.v3+json" \
-H "Content-Type: application/octet-stream" \
--data-binary @/tmp/savi.tar.gz \
"https://uploads.github.com/repos/$CIRRUS_REPO_FULL_NAME/releases/$CIRRUS_RELEASE/assets?name=${TRIPLE}-savi.tar.gz" \
'