Clean up the internal temporary file emsdk_set_env.sh/.bat in a more exact manner so that the temp file is not left around. Fixes https://github.com/kripken/emscripten/issues/2918.
This commit is contained in:
19
emsdk
19
emsdk
@@ -33,6 +33,8 @@ if platform.mac_ver()[0] != '':
|
|||||||
OSX = True
|
OSX = True
|
||||||
ENVPATH_SEPARATOR = ':'
|
ENVPATH_SEPARATOR = ':'
|
||||||
|
|
||||||
|
EMSDK_SET_ENV = 'emsdk_set_env.bat' if WINDOWS else 'emsdk_set_env.sh'
|
||||||
|
|
||||||
def win_get_environment_variable(key, system=True):
|
def win_get_environment_variable(key, system=True):
|
||||||
prev_path = os.environ['PATH']
|
prev_path = os.environ['PATH']
|
||||||
try:
|
try:
|
||||||
@@ -1006,7 +1008,7 @@ def set_active_tools(tools_to_activate, permanently_activate):
|
|||||||
# Construct a .bat script that will be invoked to set env. vars and PATH
|
# Construct a .bat script that will be invoked to set env. vars and PATH
|
||||||
if WINDOWS:
|
if WINDOWS:
|
||||||
env_string = construct_env(tools_to_activate, False)
|
env_string = construct_env(tools_to_activate, False)
|
||||||
open('emsdk_set_env.bat', 'w').write(env_string)
|
open(EMSDK_SET_ENV, 'w').write(env_string)
|
||||||
|
|
||||||
# Apply environment variables to global all users section.
|
# Apply environment variables to global all users section.
|
||||||
if WINDOWS and permanently_activate:
|
if WINDOWS and permanently_activate:
|
||||||
@@ -1139,6 +1141,12 @@ def construct_env(tools_to_activate, permanent):
|
|||||||
else:
|
else:
|
||||||
return construct_env_unix(tools_to_activate)
|
return construct_env_unix(tools_to_activate)
|
||||||
|
|
||||||
|
def silentremove(filename):
|
||||||
|
try:
|
||||||
|
os.remove(filename)
|
||||||
|
except OSError, e:
|
||||||
|
if e.errno != errno.ENOENT: raise
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
load_dot_emscripten()
|
load_dot_emscripten()
|
||||||
load_sdk_manifest()
|
load_sdk_manifest()
|
||||||
@@ -1239,17 +1247,16 @@ def main():
|
|||||||
|
|
||||||
return 0
|
return 0
|
||||||
elif cmd == 'construct_env':
|
elif cmd == 'construct_env':
|
||||||
|
silentremove(EMSDK_SET_ENV) # Clean up old temp file up front, in case of failure later before we get to write out the new one.
|
||||||
tools_to_activate = currently_active_tools()
|
tools_to_activate = currently_active_tools()
|
||||||
tools_to_activate = process_tool_list(tools_to_activate, log_errors=True)
|
tools_to_activate = process_tool_list(tools_to_activate, log_errors=True)
|
||||||
env_string = construct_env(tools_to_activate, len(sys.argv) >= 3 and 'perm' in sys.argv[2])
|
env_string = construct_env(tools_to_activate, len(sys.argv) >= 3 and 'perm' in sys.argv[2])
|
||||||
if WINDOWS:
|
open(EMSDK_SET_ENV, 'w').write(env_string)
|
||||||
open('emsdk_set_env.bat', 'w').write(env_string)
|
if LINUX or OSX: os.chmod(EMSDK_SET_ENV, 0755)
|
||||||
else:
|
|
||||||
open('emsdk_set_env.sh', 'w').write(env_string)
|
|
||||||
os.chmod('emsdk_set_env.sh', 0755)
|
|
||||||
return 0
|
return 0
|
||||||
elif cmd == 'update':
|
elif cmd == 'update':
|
||||||
update_emsdk()
|
update_emsdk()
|
||||||
|
silentremove(sdk_path(EMSDK_SET_ENV)) # Clean up litter after old emsdk update which may have left this temp file around.
|
||||||
return 0
|
return 0
|
||||||
elif cmd == 'activate':
|
elif cmd == 'activate':
|
||||||
permanently_activate = '--global' in sys.argv
|
permanently_activate = '--global' in sys.argv
|
||||||
|
|||||||
Reference in New Issue
Block a user