diff --git a/emsdk.py b/emsdk.py index 297c012..b7e52c2 100755 --- a/emsdk.py +++ b/emsdk.py @@ -59,6 +59,7 @@ VERBOSE = int(os.getenv('EMSDK_VERBOSE', '0')) TTY_OUTPUT = not os.getenv('EMSDK_NOTTY', not sys.stdout.isatty()) POWERSHELL = bool(os.getenv('EMSDK_POWERSHELL')) +CSH = bool(os.getenv('EMSDK_CSH')) WINDOWS = False if os.name == 'nt' or (os.getenv('SYSTEMROOT') is not None and 'windows' in os.getenv('SYSTEMROOT').lower()) or (os.getenv('COMSPEC') is not None and 'windows' in os.getenv('COMSPEC').lower()): @@ -157,7 +158,10 @@ emscripten_config_directory = os.path.expanduser("~/") if os.path.exists(os.path.join(emsdk_path(), '.emscripten')): emscripten_config_directory = emsdk_path() -EMSDK_SET_ENV = 'emsdk_set_env.ps1' if POWERSHELL else 'emsdk_set_env.bat' if (WINDOWS and not MSYS) else 'emsdk_set_env.sh' +EMSDK_SET_ENV = 'emsdk_set_env.ps1' if POWERSHELL \ + else 'emsdk_set_env.bat' if (WINDOWS and not MSYS) \ + else 'emsdk_set_env.csh' if CSH \ + else 'emsdk_set_env.sh' ARCHIVE_SUFFIXES = ('zip', '.tar', '.gz', '.xz', '.tbz2', '.bz2') @@ -2451,6 +2455,8 @@ def construct_env(tools_to_activate, permanent): env_string += '$env:PATH="' + newpath + '"\n' elif WINDOWS and not MSYS: env_string += 'SET PATH=' + newpath + '\n' + elif CSH: + env_string += 'setenv PATH "' + newpath + '"\n' else: env_string += 'export PATH="' + newpath + '"\n' if len(added_path) > 0: @@ -2492,6 +2498,8 @@ def construct_env(tools_to_activate, permanent): env_string += 'SETX ' + key + ' "' + value + '"\n' else: env_string += 'SET ' + key + '=' + value + '\n' + elif CSH: + env_string += 'setenv ' + key + ' "' + value + '"\n' else: env_string += 'export ' + key + '="' + value + '"\n' print(key + ' = ' + value) diff --git a/emsdk_env.csh b/emsdk_env.csh new file mode 100755 index 0000000..54cdf0e --- /dev/null +++ b/emsdk_env.csh @@ -0,0 +1,36 @@ +# This script is sourced by the user and uses +# their shell. Try not to use tcshisms. + +# Do not execute this script without sourcing, +# because it won't have any effect then. +# That is, always run this script with +# +# . ./emsdk_env.csh +# or +# source ./emsdk_env.csh +# +# instead of just plainly running with +# +# ./emsdk_env.csh +# +# which won't have any effect. +set SRC=($_) +if ("$SRC" == "") then + set SRC="$0" +else + set SRC="$SRC[2]" +endif +set CURDIR=`pwd` +cd `dirname "$SRC"` +unset SRC + +setenv EMSDK_CSH 1 + +set tmpfile=`mktemp` || exit 1 +./emsdk construct_env $tmpfile +source $tmpfile +rm -f $tmpfile + +unsetenv EMSDK_CSH + +cd "$CURDIR"