Add support for constructing a t?csh environment (#370)

This commit is contained in:
Nikolaos S. Papaspyrou
2019-10-11 00:55:27 +03:00
committed by Alon Zakai
parent cf01b11c4e
commit 27d6233c80
2 changed files with 45 additions and 1 deletions

View File

@@ -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)

36
emsdk_env.csh Executable file
View File

@@ -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"