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