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