]> git.lizzy.rs Git - rust.git/blob - src/ci/docker/scripts/emscripten.sh
Add missing emscripten.sh file
[rust.git] / src / ci / docker / scripts / emscripten.sh
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
11 set -ex
12
13 hide_output() {
14   set +x
15   on_err="
16 echo ERROR: An error was encountered with the build.
17 cat /tmp/build.log
18 exit 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
30 cd /
31 curl -L https://s3.amazonaws.com/mozilla-games/emscripten/releases/emsdk-portable.tar.gz | \
32     tar -xz
33
34 cd /emsdk-portable
35 ./emsdk update
36 hide_output ./emsdk install sdk-1.37.13-64bit
37 ./emsdk activate sdk-1.37.13-64bit
38
39 # Compile and cache libc
40 source ./emsdk_env.sh
41 echo "main(){}" > a.c
42 HOME=/emsdk-portable/ emcc a.c
43 HOME=/emsdk-portable/ emcc -s BINARYEN=1 a.c
44 rm -f a.*
45
46 # Make emsdk usable by any user
47 cp /root/.emscripten /emsdk-portable
48 chmod a+rxw -R /emsdk-portable
49
50 # node 8 is required to run wasm
51 cd /
52 curl -L https://nodejs.org/dist/v8.0.0/node-v8.0.0-linux-x64.tar.xz | \
53     tar -xJ