|
1
|
#!/bin/sh |
|
2
|
# ^^^^^^^ Please try to keep this script Bourne-compatible. |
|
3
|
######################################################################## |
|
4
|
# WARNING: emcc.sh is generated from emcc.sh.in by the configure |
|
5
|
# process. Do not edit emcc.sh directly, as it may be deleted or |
|
6
|
# overwritten by the configure script. |
|
7
|
# |
|
8
|
# A wrapper around the emcc compiler which uses configure-time state |
|
9
|
# to locate the Emscripten SDK and import the SDK's environment |
|
10
|
# script, if needed. |
|
11
|
######################################################################## |
|
12
|
# EMSDK_HOME comes from the configure --with-emsdk=/dir flag. |
|
13
|
# EMSDK_ENV_SH is ${thatDir}/emsdk_env.sh and is also set by the |
|
14
|
# configure process. |
|
15
|
EMSDK_HOME="@EMSDK_HOME@" |
|
16
|
EMSDK_ENV_SH="@EMSDK_ENV_SH@" |
|
17
|
emcc="@BIN_EMCC@" |
|
18
|
|
|
19
|
if [ x = "x${emcc}" ]; then |
|
20
|
emcc=`which emcc 2>/dev/null` |
|
21
|
fi |
|
22
|
|
|
23
|
if [ x = "x${emcc}" ]; then |
|
24
|
# If emcc is not found in the path, try to find it via an emsdk |
|
25
|
# installation. The SDK variant is the official installation style |
|
26
|
# supported by the Emscripten project, but emcc is also available |
|
27
|
# via package managers on some OSes. |
|
28
|
if [ x = "x${EMSDK_HOME}" ]; then |
|
29
|
echo "EMSDK_HOME is not set. Pass --with-emsdk=/path/to/emsdk" \ |
|
30
|
"to the configure script." 1>&2 |
|
31
|
exit 1 |
|
32
|
fi |
|
33
|
|
|
34
|
if [ x = "x${EMSDK_ENV_SH}" ]; then |
|
35
|
if [ -f "${EMSDK_HOME}/emsdk_env.sh" ]; then |
|
36
|
EMSDK_ENV_SH="${EMSDK_HOME}/emsdk_env.sh" |
|
37
|
else |
|
38
|
echo "EMSDK_ENV_SH is not set. Expecting configure script to set it." 1>&2 |
|
39
|
exit 2 |
|
40
|
fi |
|
41
|
fi |
|
42
|
|
|
43
|
if [ ! -f "${EMSDK_ENV_SH}" ]; then |
|
44
|
echo "emsdk_env script not found: $EMSDK_ENV_SH" 1>&2 |
|
45
|
exit 3 |
|
46
|
fi |
|
47
|
|
|
48
|
# $EMSDK is part of the state set by emsdk_env.sh. |
|
49
|
if [ x = "x${EMSDK}" ]; then |
|
50
|
EMSDK_QUIET=1 |
|
51
|
export EMSDK_QUIET |
|
52
|
# ^^^ Squelches informational output from ${EMSDK_ENV_SH}. |
|
53
|
source "${EMSDK_ENV_SH}" || { |
|
54
|
rc=$? |
|
55
|
echo "Error sourcing ${EMSDK_ENV_SH}" |
|
56
|
exit $rc |
|
57
|
} |
|
58
|
fi |
|
59
|
emcc=`which emcc 2>/dev/null` |
|
60
|
if [ x = "x${emcc}" ]; then |
|
61
|
echo "emcc not found in PATH. Normally that's set up by ${EMSDK_ENV_SH}." 1>&2 |
|
62
|
exit 4 |
|
63
|
fi |
|
64
|
fi |
|
65
|
|
|
66
|
exec $emcc "$@" |
|
67
|
|