rust-libc/ci/emscripten.sh

44 lines
968 B
Bash
Raw Normal View History

2020-04-11 12:16:45 +02:00
#!/usr/bin/env bash
set -ex
2020-08-20 05:53:03 +02:00
EMSDK_VERSION=1.39.20
2020-06-02 06:26:51 +02:00
hide_output() {
set +x
on_err="
echo ERROR: An error was encountered with the build.
cat /tmp/build.log
exit 1
"
2018-11-19 15:49:56 +01:00
trap '$on_err' ERR
bash -c "while true; do sleep 30; echo \$(date) - building ...; done" &
PING_LOOP_PID=$!
2018-11-19 15:49:56 +01:00
"${@}" &> /tmp/build.log
trap - ERR
kill $PING_LOOP_PID
rm -f /tmp/build.log
set -x
}
2019-08-26 22:14:38 +02:00
git clone https://github.com/emscripten-core/emsdk.git /emsdk-portable
cd /emsdk-portable
2020-06-02 06:26:51 +02:00
hide_output ./emsdk install "${EMSDK_VERSION}"
./emsdk activate "${EMSDK_VERSION}"
# Compile and cache libc
2018-11-19 15:49:56 +01:00
# shellcheck disable=SC1091
source ./emsdk_env.sh
echo "main(){}" > a.c
HOME=/emsdk-portable/ emcc a.c
rm -f a.*
# Make emsdk usable by any user
chmod a+rxw -R /emsdk-portable
# node 8 is required to run wasm
2020-08-20 05:53:03 +02:00
# NOTE: Do not forget to sync Node.js version with `emscripten-entry.sh`!
cd /
2020-08-20 05:53:03 +02:00
curl --retry 5 -L https://nodejs.org/dist/v12.18.3/node-v12.18.3-linux-x64.tar.xz | \
tar -xJ