comparison third_party/emsdk/emsdk_env.sh @ 186:8cf4ec5e2191 hg-web

Fixed merge conflict.
author MrJuneJune <me@mrjunejune.com>
date Fri, 23 Jan 2026 22:38:59 -0800
parents 8d17f6e6e290
children
comparison
equal deleted inserted replaced
176:fed99fc04e12 186:8cf4ec5e2191
1 # This script is sourced by the user and uses
2 # their shell.
3 #
4 # This script tries to find its location but
5 # this does not work in every shell.
6 #
7 # It is known to work in bash, zsh and ksh
8 #
9 # Do not execute this script without sourcing,
10 # because it won't have any effect then.
11 # That is, always run this script with
12 #
13 # . /path/to/emsdk_env.sh
14 #
15 # or
16 #
17 # source /path/to/emsdk_env.sh
18 #
19 # instead of just plainly running with
20 #
21 # ./emsdk_env.sh
22 #
23 # which won't have any effect.
24
25 CURRENT_SCRIPT=
26 DIR="."
27
28 # use shell specific method to get the path
29 # to the current file being source'd.
30 #
31 # To add a shell, add another conditional below,
32 # then add tests to scripts/test_source_env.sh
33
34 if [ -n "${BASH_SOURCE-}" ]; then
35 CURRENT_SCRIPT="$BASH_SOURCE"
36 elif [ -n "${ZSH_VERSION-}" ]; then
37 CURRENT_SCRIPT="${(%):-%x}"
38 elif [ -n "${KSH_VERSION-}" ]; then
39 CURRENT_SCRIPT=${.sh.file}
40 fi
41
42 if [ -n "${CURRENT_SCRIPT-}" ]; then
43 DIR=$(dirname "$CURRENT_SCRIPT")
44 if [ -h "$CURRENT_SCRIPT" ]; then
45 # Now work out actual DIR since this is part of a symlink.
46 # Since we can't be sure that readlink or realpath
47 # are available, use tools more likely to be installed.
48 # (This will still fail if sed is not available.)
49 SYMDIR=$(dirname "$(ls -l "$CURRENT_SCRIPT" | sed -n "s/.*-> //p")")
50 if [ -z "$SYMDIR" ]; then
51 SYMDIR="."
52 fi
53 FULLDIR="$DIR/$SYMDIR"
54 DIR=$(cd "$FULLDIR" > /dev/null 2>&1; /bin/pwd)
55 unset SYMDIR
56 unset FULLDIR
57 fi
58 fi
59 unset CURRENT_SCRIPT
60
61 if [ ! -f "$DIR/emsdk.py" ]; then
62 echo "Error: unable to determine 'emsdk' directory. Perhaps you are using a shell or" 1>&2
63 echo " environment that this script does not support." 1>&2
64 echo 1>&2
65 echo "A possible solution is to source this script while in the 'emsdk' directory." 1>&2
66 echo 1>&2
67 unset DIR
68 return
69 fi
70
71 # Force emsdk to use bash syntax so that this works in windows + bash too
72 eval `EMSDK_BASH=1 "$DIR/emsdk" construct_env`
73 unset DIR