support powershell env
This commit is contained in:
Родитель
024e3bb3b4
Коммит
605c83a6d1
11
emsdk
11
emsdk
|
@ -31,6 +31,8 @@ binaryen_git_repo = 'https://github.com/WebAssembly/binaryen.git'
|
|||
# Enable this to do very verbose printing about the different steps that are being run. Useful for debugging.
|
||||
VERBOSE = bool(os.getenv('EMSDK_VERBOSE')) if os.getenv('EMSDK_VERBOSE') != None else False
|
||||
|
||||
POWERSHELL = bool(os.getenv('EMSDK_POWERSHELL'))
|
||||
|
||||
WINDOWS = False
|
||||
if os.name == 'nt' or (os.getenv('SYSTEMROOT') != None and 'WINDOWS' in os.getenv('SYSTEMROOT')) or (os.getenv('COMSPEC') != None and 'WINDOWS' in os.getenv('COMSPEC')):
|
||||
WINDOWS = True
|
||||
|
@ -80,7 +82,7 @@ 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.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.sh'
|
||||
|
||||
# Finds the given executable 'program' in PATH. Operates like the Unix tool 'which'.
|
||||
def which(program):
|
||||
|
@ -1880,7 +1882,8 @@ def construct_env(tools_to_activate, permanent):
|
|||
# else:
|
||||
|
||||
if os.environ['PATH'] != newpath: # Don't bother setting the path if there are no changes.
|
||||
if WINDOWS and not MSYS: env_string += 'SET PATH=' + newpath + '\n'
|
||||
if POWERSHELL: env_string += '$env:PATH="' + newpath + '"\n'
|
||||
elif WINDOWS and not MSYS: env_string += 'SET PATH=' + newpath + '\n'
|
||||
else: env_string += 'export PATH="' + newpath + '"\n'
|
||||
if len(added_path) > 0:
|
||||
print('Adding directories to PATH:')
|
||||
|
@ -1912,7 +1915,9 @@ def construct_env(tools_to_activate, permanent):
|
|||
if len(env_vars_to_add) > 0:
|
||||
print('Setting environment variables:')
|
||||
for key, value in env_vars_to_add:
|
||||
if WINDOWS and not MSYS:
|
||||
if POWERSHELL:
|
||||
env_string += '$env:' + key + '="' + value + '"\n'
|
||||
elif WINDOWS and not MSYS:
|
||||
if permanent:
|
||||
env_string += 'SETX ' + key + ' "' + value + '"\n'
|
||||
else:
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
@SET PREVPATH=%PATH%
|
||||
|
||||
:: Find python from an explicit location relative to the Emscripten SDK.
|
||||
@IF EXIST "%~dp0python\2.7.5.3_64bit\python.exe" (
|
||||
@SET EMSDK_PY="%~dp0python\2.7.5.3_64bit\python.exe"
|
||||
|
@ -21,15 +19,13 @@
|
|||
@GOTO end
|
||||
)
|
||||
|
||||
:: As last resort, access from PATH.
|
||||
:: As a last resort, access from PATH.
|
||||
@SET EMSDK_PY=python
|
||||
|
||||
:end
|
||||
@call %EMSDK_PY% "%~dp0\emsdk" %*
|
||||
|
||||
@set EMSDK_PY=
|
||||
@set PATH=%PREVPATH%
|
||||
@set PREVPATH=
|
||||
|
||||
:: python is not able to set environment variables to the parent calling process, so
|
||||
:: therefore have it craft a .bat file, which we invoke after finishing python execution,
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
$ScriptDirectory = Split-Path -parent $PSCommandPath
|
||||
|
||||
$PythonLocations = $(
|
||||
"python\2.7.5.3_64bit\python.exe",
|
||||
"python\2.7.5.3_32bit\python.exe",
|
||||
"python\2.7.5_64bit\python.exe",
|
||||
"python\2.7.5.1_32bit\python.exe"
|
||||
)
|
||||
|
||||
# Find python from an explicit location relative to the Emscripten SDK.
|
||||
foreach ($Location in $PythonLocations) {
|
||||
$FullLocation = Join-Path $ScriptDirectory $Location
|
||||
if (Test-Path $FullLocation) {
|
||||
$EMSDK_PY = $FullLocation
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
# As a last resort, access from PATH.
|
||||
if (-Not $EMSDK_PY) {
|
||||
$EMSDK_PY = "python"
|
||||
}
|
||||
|
||||
# Tell EMSDK to create environment variable setter as a .ps1 file
|
||||
$env:EMSDK_POWERSHELL = 1
|
||||
|
||||
& $EMSDK_PY "$ScriptDirectory/emsdk" $args
|
||||
|
||||
# python is not able to set environment variables to the parent calling process, so
|
||||
# therefore have it craft a .ps1 file, which we invoke after finishing python execution,
|
||||
# to set up the environment variables
|
||||
if (Test-Path "emsdk_set_env.ps1") {
|
||||
& emsdk_set_env.ps1
|
||||
Remove-Item emsdk_set_env.ps1
|
||||
}
|
||||
|
||||
Remove-Item Env:\EMSDK_POWERSHELL
|
|
@ -0,0 +1,2 @@
|
|||
$ScriptDirectory = Split-Path -parent $PSCommandPath
|
||||
& "$ScriptDirectory/emsdk.ps1" construct_env $args
|
Загрузка…
Ссылка в новой задаче