xref: /rust-libc-0.2.174/ci/emscripten.sh (revision b9986d9d)
1#!/usr/bin/env bash
2
3set -ex
4
5hide_output() {
6  set +x
7  on_err="
8echo ERROR: An error was encountered with the build.
9cat /tmp/build.log
10exit 1
11"
12  trap '$on_err' ERR
13  bash -c "while true; do sleep 30; echo \$(date) - building ...; done" &
14  PING_LOOP_PID=$!
15  "${@}" &> /tmp/build.log
16  trap - ERR
17  kill $PING_LOOP_PID
18  rm -f /tmp/build.log
19  set -x
20}
21
22git clone https://github.com/emscripten-core/emsdk.git /emsdk-portable
23cd /emsdk-portable
24# FIXME: switch to an upstream install once
25# https://github.com/rust-lang/rust/pull/63649 lands
26hide_output ./emsdk install 1.39.12
27./emsdk activate 1.39.12
28
29# Compile and cache libc
30# shellcheck disable=SC1091
31source ./emsdk_env.sh
32echo "main(){}" > a.c
33HOME=/emsdk-portable/ emcc a.c
34rm -f a.*
35
36# Make emsdk usable by any user
37cp /root/.emscripten /emsdk-portable
38chmod a+rxw -R /emsdk-portable
39
40# node 8 is required to run wasm
41cd /
42curl --retry 5 -L https://nodejs.org/dist/v12.16.2/node-v12.16.2-linux-x64.tar.xz | \
43    tar -xJ
44