Revise the messages printed during toolchain activation to be more user-friendly.
This commit is contained in:
34
emsdk
34
emsdk
@@ -811,8 +811,8 @@ def remove_nonexisting_tools(tool_list, log_errors=True):
|
|||||||
i += 1
|
i += 1
|
||||||
return tool_list
|
return tool_list
|
||||||
|
|
||||||
# Reconfigure .emscripten to choose the currently activated toolset, set PATH and other environment variables.
|
# Expands dependencies for each tool, and removes ones that don't exist.
|
||||||
def set_active_tools(tools_to_activate, permanently_activate):
|
def process_tool_list(tools_to_activate, log_errors=True):
|
||||||
i = 0
|
i = 0
|
||||||
# Gather dependencies for each tool
|
# Gather dependencies for each tool
|
||||||
while i < len(tools_to_activate):
|
while i < len(tools_to_activate):
|
||||||
@@ -821,7 +821,7 @@ def set_active_tools(tools_to_activate, permanently_activate):
|
|||||||
tools_to_activate = tools_to_activate[:i] + deps + tools_to_activate[i:]
|
tools_to_activate = tools_to_activate[:i] + deps + tools_to_activate[i:]
|
||||||
i += len(deps)+1
|
i += len(deps)+1
|
||||||
|
|
||||||
tools_to_activate = remove_nonexisting_tools(tools_to_activate, log_errors=True)
|
tools_to_activate = remove_nonexisting_tools(tools_to_activate, log_errors=log_errors)
|
||||||
|
|
||||||
# Remove conflicting tools
|
# Remove conflicting tools
|
||||||
i = 0
|
i = 0
|
||||||
@@ -836,9 +836,20 @@ def set_active_tools(tools_to_activate, permanently_activate):
|
|||||||
i -= 1
|
i -= 1
|
||||||
j += 1
|
j += 1
|
||||||
i += 1
|
i += 1
|
||||||
|
return tools_to_activate
|
||||||
|
|
||||||
|
# Reconfigure .emscripten to choose the currently activated toolset, set PATH and other environment variables.
|
||||||
|
# Returns the full list of deduced tools that are now active.
|
||||||
|
def set_active_tools(tools_to_activate, permanently_activate):
|
||||||
|
tools_to_activate = process_tool_list(tools_to_activate, log_errors=True)
|
||||||
|
|
||||||
generate_dot_emscripten(tools_to_activate)
|
generate_dot_emscripten(tools_to_activate)
|
||||||
|
|
||||||
|
# Construct a .bat script that will be invoked to set env. vars and PATH
|
||||||
|
if WINDOWS:
|
||||||
|
env_string = construct_env(tools_to_activate, False)
|
||||||
|
open('emsdk_set_env.bat', '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:
|
||||||
# Individual env. vars
|
# Individual env. vars
|
||||||
@@ -851,7 +862,9 @@ def set_active_tools(tools_to_activate, permanently_activate):
|
|||||||
if len(newpath) < 1024:
|
if len(newpath) < 1024:
|
||||||
win_set_environment_variable('PATH', newpath, system=True)
|
win_set_environment_variable('PATH', newpath, system=True)
|
||||||
else:
|
else:
|
||||||
print >> sys.stderr, 'ERROR! The current PATH is too large (more than 1024 characters), unable to add Emscripten environment to PATH via command-line! Please do this via the system user interface.'
|
print >> sys.stderr, 'ERROR! The new PATH is more than 1024 characters long! A PATH this long cannot be set via command line: please add the PATHs specified above to system PATH manually via Control Panel.'
|
||||||
|
|
||||||
|
return tools_to_activate
|
||||||
|
|
||||||
def currently_active_sdk():
|
def currently_active_sdk():
|
||||||
for sdk in reversed(sdks):
|
for sdk in reversed(sdks):
|
||||||
@@ -890,7 +903,7 @@ def adjusted_path(tools_to_activate, log_additions=False):
|
|||||||
def construct_env_windows(tools_to_activate, permanent):
|
def construct_env_windows(tools_to_activate, permanent):
|
||||||
env_string = ''
|
env_string = ''
|
||||||
newpath, added_path = adjusted_path(tools_to_activate)
|
newpath, added_path = adjusted_path(tools_to_activate)
|
||||||
|
|
||||||
# Dont permanently add to PATH, since this will break the whole system if there are more than 1024 chars in PATH.
|
# Dont permanently add to PATH, since this will break the whole system if there are more than 1024 chars in PATH.
|
||||||
# (SETX truncates to set only 1024 chars)
|
# (SETX truncates to set only 1024 chars)
|
||||||
# if permanent:
|
# if permanent:
|
||||||
@@ -900,7 +913,7 @@ def construct_env_windows(tools_to_activate, permanent):
|
|||||||
if os.environ['PATH'] != newpath: # Don't bother setting the path if there are no changes.
|
if os.environ['PATH'] != newpath: # Don't bother setting the path if there are no changes.
|
||||||
env_string += 'SET PATH=' + newpath + '\n'
|
env_string += 'SET PATH=' + newpath + '\n'
|
||||||
if len(added_path) > 0:
|
if len(added_path) > 0:
|
||||||
print 'The following directories have been added to PATH:'
|
print 'Adding directories to PATH:'
|
||||||
for item in added_path:
|
for item in added_path:
|
||||||
print 'PATH += ' + item
|
print 'PATH += ' + item
|
||||||
print ''
|
print ''
|
||||||
@@ -914,13 +927,14 @@ def construct_env_windows(tools_to_activate, permanent):
|
|||||||
env_vars_to_add += [(key, value)]
|
env_vars_to_add += [(key, value)]
|
||||||
|
|
||||||
if len(env_vars_to_add) > 0:
|
if len(env_vars_to_add) > 0:
|
||||||
print 'The following environment variables have been set:'
|
print 'Setting environment variables:'
|
||||||
for key, value in env_vars_to_add:
|
for key, value in env_vars_to_add:
|
||||||
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'
|
||||||
print key + ' = ' + value
|
print key + ' = ' + value
|
||||||
|
print ''
|
||||||
return env_string
|
return env_string
|
||||||
|
|
||||||
def construct_env(tools_to_activate, permanent):
|
def construct_env(tools_to_activate, permanent):
|
||||||
@@ -1034,11 +1048,7 @@ def main():
|
|||||||
print "Error: No tool or SDK found by name '" + sys.argv[i] + "'."
|
print "Error: No tool or SDK found by name '" + sys.argv[i] + "'."
|
||||||
return 1
|
return 1
|
||||||
tools_to_activate += [tool]
|
tools_to_activate += [tool]
|
||||||
set_active_tools(tools_to_activate, permanently_activate=permanently_activate)
|
tools_to_activate = set_active_tools(tools_to_activate, permanently_activate=permanently_activate)
|
||||||
|
|
||||||
if WINDOWS:
|
|
||||||
env_string = construct_env(tools_to_activate, False)
|
|
||||||
open('emsdk_set_env.bat', 'w').write(env_string)
|
|
||||||
return 0
|
return 0
|
||||||
elif cmd == 'install':
|
elif cmd == 'install':
|
||||||
if len(sys.argv) <= 2:
|
if len(sys.argv) <= 2:
|
||||||
|
|||||||
Reference in New Issue
Block a user