Allow EMCC_BASH to force bash during construct_env (#493)
This allows `emsdk_env.sh` to work under bash for windows even in the absence of the `MSYSTEM` environment variable (which seems to be the setup on circle CI.
This commit is contained in:
41
emsdk.py
41
emsdk.py
@@ -48,13 +48,9 @@ zips_subdir = 'zips/'
|
|||||||
VERBOSE = int(os.getenv('EMSDK_VERBOSE', '0'))
|
VERBOSE = int(os.getenv('EMSDK_VERBOSE', '0'))
|
||||||
TTY_OUTPUT = not os.getenv('EMSDK_NOTTY', not sys.stdout.isatty())
|
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
|
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()):
|
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()):
|
||||||
WINDOWS = True
|
WINDOWS = True
|
||||||
ENVPATH_SEPARATOR = ';'
|
|
||||||
|
|
||||||
MINGW = False
|
MINGW = False
|
||||||
MSYS = False
|
MSYS = False
|
||||||
@@ -72,15 +68,35 @@ if os.getenv('MSYSTEM'):
|
|||||||
OSX = False
|
OSX = False
|
||||||
if platform.mac_ver()[0] != '':
|
if platform.mac_ver()[0] != '':
|
||||||
OSX = True
|
OSX = True
|
||||||
ENVPATH_SEPARATOR = ':'
|
|
||||||
|
|
||||||
LINUX = False
|
LINUX = False
|
||||||
if not OSX and (platform.system() == 'Linux' or os.name == 'posix'):
|
if not OSX and (platform.system() == 'Linux' or os.name == 'posix'):
|
||||||
LINUX = True
|
LINUX = True
|
||||||
ENVPATH_SEPARATOR = ':'
|
|
||||||
|
|
||||||
UNIX = (OSX or LINUX)
|
UNIX = (OSX or LINUX)
|
||||||
|
|
||||||
|
|
||||||
|
# Pick which shell of 4 shells to use
|
||||||
|
POWERSHELL = bool(os.getenv('EMSDK_POWERSHELL'))
|
||||||
|
CSH = bool(os.getenv('EMSDK_CSH'))
|
||||||
|
CMD = bool(os.getenv('EMSDK_CMD'))
|
||||||
|
BASH = bool(os.getenv('EMSDK_BASH'))
|
||||||
|
if WINDOWS and BASH:
|
||||||
|
MSYS = True
|
||||||
|
|
||||||
|
if not CSH and not POWERSHELL and not BASH and not CMD:
|
||||||
|
# Fall back to default of `cmd` on windows and `bash` otherwise
|
||||||
|
if WINDOWS and not MSYS:
|
||||||
|
CMD = True
|
||||||
|
else:
|
||||||
|
BASH = True
|
||||||
|
|
||||||
|
if WINDOWS:
|
||||||
|
ENVPATH_SEPARATOR = ';'
|
||||||
|
else:
|
||||||
|
ENVPATH_SEPARATOR = ':'
|
||||||
|
|
||||||
|
|
||||||
ARCH = 'unknown'
|
ARCH = 'unknown'
|
||||||
# platform.machine() may return AMD64 on windows, so standardize the case.
|
# platform.machine() may return AMD64 on windows, so standardize the case.
|
||||||
machine = platform.machine().lower()
|
machine = platform.machine().lower()
|
||||||
@@ -2583,12 +2599,15 @@ def construct_env(tools_to_activate, permanent):
|
|||||||
if os.environ['PATH'] != newpath:
|
if os.environ['PATH'] != newpath:
|
||||||
if POWERSHELL:
|
if POWERSHELL:
|
||||||
env_string += '$env:PATH="' + newpath + '"\n'
|
env_string += '$env:PATH="' + newpath + '"\n'
|
||||||
elif WINDOWS and not MSYS:
|
elif CMD:
|
||||||
env_string += 'SET PATH=' + newpath + '\n'
|
env_string += 'SET PATH=' + newpath + '\n'
|
||||||
elif CSH:
|
elif CSH:
|
||||||
env_string += 'setenv PATH "' + newpath + '"\n'
|
env_string += 'setenv PATH "' + newpath + '"\n'
|
||||||
else:
|
elif BASH:
|
||||||
env_string += 'export PATH="' + newpath + '"\n'
|
env_string += 'export PATH="' + newpath + '"\n'
|
||||||
|
else:
|
||||||
|
assert False
|
||||||
|
|
||||||
if len(added_path) > 0:
|
if len(added_path) > 0:
|
||||||
print('Adding directories to PATH:')
|
print('Adding directories to PATH:')
|
||||||
for item in added_path:
|
for item in added_path:
|
||||||
@@ -2623,15 +2642,17 @@ def construct_env(tools_to_activate, permanent):
|
|||||||
for key, value in env_vars_to_add:
|
for key, value in env_vars_to_add:
|
||||||
if POWERSHELL:
|
if POWERSHELL:
|
||||||
env_string += '$env:' + key + '="' + value + '"\n'
|
env_string += '$env:' + key + '="' + value + '"\n'
|
||||||
elif WINDOWS and not MSYS:
|
elif CMD:
|
||||||
if permanent:
|
if permanent:
|
||||||
env_string += 'SETX ' + key + ' "' + value + '"\n'
|
env_string += 'SETX ' + key + ' "' + value + '"\n'
|
||||||
else:
|
else:
|
||||||
env_string += 'SET ' + key + '=' + value + '\n'
|
env_string += 'SET ' + key + '=' + value + '\n'
|
||||||
elif CSH:
|
elif CSH:
|
||||||
env_string += 'setenv ' + key + ' "' + value + '"\n'
|
env_string += 'setenv ' + key + ' "' + value + '"\n'
|
||||||
else:
|
elif BASH:
|
||||||
env_string += 'export ' + key + '="' + value + '"\n'
|
env_string += 'export ' + key + '="' + value + '"\n'
|
||||||
|
else:
|
||||||
|
assert False
|
||||||
print(key + ' = ' + value)
|
print(key + ' = ' + value)
|
||||||
print('')
|
print('')
|
||||||
return env_string
|
return env_string
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#!/bin/bash
|
||||||
# This script is sourced by the user and uses
|
# This script is sourced by the user and uses
|
||||||
# their shell. Try not to use bashisms.
|
# their shell. Try not to use bashisms.
|
||||||
|
|
||||||
@@ -23,7 +24,8 @@ cd "$(dirname "$SRC")"
|
|||||||
unset SRC
|
unset SRC
|
||||||
|
|
||||||
tmpfile=`mktemp` || exit 1
|
tmpfile=`mktemp` || exit 1
|
||||||
./emsdk construct_env $tmpfile
|
# Force emsdk to use bash syntax so that this works in windows + bash too
|
||||||
|
EMSDK_BASH=1 ./emsdk construct_env $tmpfile
|
||||||
. $tmpfile
|
. $tmpfile
|
||||||
rm -f $tmpfile
|
rm -f $tmpfile
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user