1#!/usr/bin/env bash 2# Copyright 2017 The Rust Project Developers. See the COPYRIGHT 3# file at the top-level directory of this distribution and at 4# http://rust-lang.org/COPYRIGHT. 5# 6# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or 7# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license 8# <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your 9# option. This file may not be copied, modified, or distributed 10# except according to those terms. 11 12set -ex 13 14hide_output() { 15 set +x 16 on_err=" 17echo ERROR: An error was encountered with the build. 18cat /tmp/build.log 19exit 1 20" 21 trap '$on_err' ERR 22 bash -c "while true; do sleep 30; echo \$(date) - building ...; done" & 23 PING_LOOP_PID=$! 24 "${@}" &> /tmp/build.log 25 trap - ERR 26 kill $PING_LOOP_PID 27 rm -f /tmp/build.log 28 set -x 29} 30 31cd / 32curl --retry 5 -L https://s3.amazonaws.com/mozilla-games/emscripten/releases/emsdk-portable.tar.gz | \ 33 tar -xz 34 35cd /emsdk-portable 36./emsdk update 37hide_output ./emsdk install sdk-1.38.15-64bit 38./emsdk activate sdk-1.38.15-64bit 39 40# Compile and cache libc 41# shellcheck disable=SC1091 42source ./emsdk_env.sh 43echo "main(){}" > a.c 44HOME=/emsdk-portable/ emcc a.c 45HOME=/emsdk-portable/ emcc -s BINARYEN=1 a.c 46rm -f a.* 47 48# Make emsdk usable by any user 49cp /root/.emscripten /emsdk-portable 50chmod a+rxw -R /emsdk-portable 51 52# node 8 is required to run wasm 53cd / 54curl --retry 5 -L https://nodejs.org/dist/v12.3.1/node-v12.3.1-linux-x64.tar.xz | \ 55 tar -xJ 56 57