Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 9244ac9

Browse files
committedJul 3, 2014
Make emsdk aware when running in a shell that doesn't have a particular tool active, but .emscripten has it set up, and print a help message when calling 'emsdk list'. Fix line endings in emcmdprompt.bat.
1 parent 2ef3770 commit 9244ac9

File tree

2 files changed

+30
-9
lines changed

2 files changed

+30
-9
lines changed
 

‎emcmdprompt.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
@cmd /k call emsdk_env.bat
1+
@cmd /k call emsdk_env.bat

‎emsdk

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -580,12 +580,6 @@ class Tool:
580580
if not tool.is_active():
581581
return False
582582

583-
if WINDOWS and hasattr(self, 'activated_env'):
584-
(key, value) = parse_key_value(self.activated_environment())
585-
env_var = win_get_active_environment_variable(key)
586-
if env_var != value:
587-
return False
588-
589583
activated_cfg = self.activated_config()
590584
if activated_cfg == '':
591585
return len(deps) > 0
@@ -598,6 +592,23 @@ class Tool:
598592
return True
599593
return False
600594

595+
# Returns true if the system environment variables requires by this tool are currently active.
596+
def is_env_active(self):
597+
if hasattr(self, 'activated_env'):
598+
(key, value) = parse_key_value(self.activated_environment())
599+
if not key in os.environ or os.environ[key] != value:
600+
return False
601+
# if WINDOWS:
602+
# env_var = win_get_active_environment_variable(key)
603+
# if env_var != value:
604+
# return False
605+
if hasattr(self, 'activated_path'):
606+
path = self.expand_vars(self.activated_path).replace('\\', '/')
607+
path_items = os.environ['PATH'].replace('\\', '/').split(ENVPATH_SEPARATOR)
608+
if not path in path_items:
609+
return False
610+
return True
611+
601612
def win_activate_env_vars(self, permanently_activate):
602613
if WINDOWS and hasattr(self, 'activated_env'):
603614
(key, value) = parse_key_value(self.activated_environment())
@@ -988,6 +999,7 @@ def main():
988999
if cmd == 'list':
9891000
print ''
9901001
show_old = len(sys.argv) >= 3 and sys.argv[2] == '--old'
1002+
has_partially_active_tools = False
9911003
if len(tools) > 0:
9921004
print 'The following individual tools exist:'
9931005
for tool in tools:
@@ -997,7 +1009,13 @@ def main():
9971009
installed = '\tINSTALLED' if tool.is_installed() else ''
9981010
else:
9991011
installed = '\tNot available: ' + tool.can_be_installed()
1000-
active = '*' if tool.is_active() else ' '
1012+
tool_is_active = tool.is_active()
1013+
tool_is_env_active = tool_is_active and tool.is_env_active()
1014+
if tool_is_env_active: active = ' * '
1015+
elif tool_is_active:
1016+
active = '(*)'
1017+
has_partially_active_tools = True
1018+
else: active = ' '
10011019
print ' ' + active + ' {0: <25}'.format(str(tool)) + installed
10021020
print ''
10031021
else:
@@ -1013,14 +1031,17 @@ def main():
10131031
active = '*' if sdk.is_active() else ' '
10141032
print ' ' + active + ' {0: <25}'.format(str(sdk)) + installed
10151033
print ''
1016-
print 'The items marked with * are activated for the current user.'
1034+
print 'Items marked with * are activated for the current user.'
1035+
if has_partially_active_tools:
1036+
print 'Items marked with (*) are selected for use, but your current shell environment is not configured to use them. Type "emsdk_env.bat" to set up your current shell to use them, or call "emsdk activate --global <name_of_sdk>" to permanently activate them.'
10171037
if not show_old:
10181038
print ''
10191039
print "To access the historical archived versions, type 'emsdk list --old'"
10201040

10211041
return 0
10221042
elif cmd == 'construct_env':
10231043
tools_to_activate = currently_active_tools()
1044+
tools_to_activate = process_tool_list(tools_to_activate, log_errors=True)
10241045
env_string = construct_env(tools_to_activate, len(sys.argv) >= 3 and 'perm' in sys.argv[2])
10251046
if WINDOWS:
10261047
open('emsdk_set_env.bat', 'w').write(env_string)

0 commit comments

Comments
 (0)
Please sign in to comment.