forked from livecode/livecode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathemscripten-javascriptify.sh
More file actions
executable file
·50 lines (41 loc) · 1.05 KB
/
emscripten-javascriptify.sh
File metadata and controls
executable file
·50 lines (41 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/bin/bash
# This script runs the command that javascript-ifies the bitcode files produced
# by the Emscripten compiler.
set -e
# Parameters:
# input: bitcode file to javascriptify
# output: the output HTML file
# exports: JSON file containing list of exported functions
# whitelist: JSON file containing list of emterpreted functions
# other args: additional javascript libraries to include
#
input=$1
output=$2
whitelist=$3
preamble=$4
shift 4
for lib in $@ ; do
libs+=\ --js-library\ "${lib}"
done
EMCC=${EMCC:-emcc}
BUILDTYPE=${BUILDTYPE:-Debug}
# Optimisation flags for the Emscripten bitcode-to-javascript step:
#
# -Os Optimise for a balance of size and speed
#
if [ "${BUILDTYPE}" = "Release" ] ; then
optimisation_flags="-Os -g0"
else
optimisation_flags="-O2 -g3"
fi
${EMCC} ${optimisation_flags} ${CFLAGS} \
"${input}" \
-o "${output}" \
-s EMTERPRETIFY_WHITELIST=@"${whitelist}" \
-s ASSERTIONS=1 \
-s EMTERPRETIFY=1 \
-s EMTERPRETIFY_ASYNC=1 \
-s ALLOW_MEMORY_GROWTH=1 \
-s TOTAL_MEMORY=67108864 \
--pre-js "${preamble}" \
${libs}