Add support for multiple environment items to be present in activated_env, separated by semicolon ;.

This commit is contained in:
Jukka Jylänki
2018-07-19 12:17:56 +03:00
parent 18b21ddad6
commit cac082054a

36
emsdk
View File

@@ -1270,14 +1270,13 @@ class Tool:
# Returns true if the system environment variables requires by this tool are currently active. # Returns true if the system environment variables requires by this tool are currently active.
def is_env_active(self): def is_env_active(self):
if hasattr(self, 'activated_env'): if hasattr(self, 'activated_env'):
(key, value) = parse_key_value(self.activated_environment()) envs = self.activated_environment().split(';')
if not key in os.environ or to_unix_path(os.environ[key]) != to_unix_path(value): for env in envs:
if VERBOSE: print(str(self) + ' is not active, because environment variable key="' + key + '" has value "' + str(os.getenv(key)) + '" but should have value "' + value + '"') (key, value) = parse_key_value(env)
return False if not key in os.environ or to_unix_path(os.environ[key]) != to_unix_path(value):
# if WINDOWS: if VERBOSE: print(str(self) + ' is not active, because environment variable key="' + key + '" has value "' + str(os.getenv(key)) + '" but should have value "' + value + '"')
# env_var = win_get_active_environment_variable(key) return False
# if env_var != value:
# return False
if hasattr(self, 'activated_path'): if hasattr(self, 'activated_path'):
path = self.expand_vars(self.activated_path).replace('\\', '/') path = self.expand_vars(self.activated_path).replace('\\', '/')
path = path.split(ENVPATH_SEPARATOR) path = path.split(ENVPATH_SEPARATOR)
@@ -1290,11 +1289,14 @@ class Tool:
def win_activate_env_vars(self, permanently_activate): def win_activate_env_vars(self, permanently_activate):
if WINDOWS and hasattr(self, 'activated_env'): if WINDOWS and hasattr(self, 'activated_env'):
(key, value) = parse_key_value(self.activated_environment()) envs = self.activated_environment().split(';')
if permanently_activate: for env in envs:
win_delete_environment_variable(key, False) # If there is an env var for the LOCAL USER with same name, it will hide the system var, so must remove that first. (key, value) = parse_key_value(env)
win_set_environment_variable(key, value, permanently_activate) if permanently_activate:
win_delete_environment_variable(key, False) # If there is an env var for the LOCAL USER with same name, it will hide the system var, so must remove that first.
win_set_environment_variable(key, value, permanently_activate)
# If this tool can be installed on this system, this function returns True. # If this tool can be installed on this system, this function returns True.
# Otherwise, this function returns a string that describes the reason why this tool is not available. # Otherwise, this function returns a string that describes the reason why this tool is not available.
@@ -1955,10 +1957,12 @@ def construct_env(tools_to_activate, permanent):
for tool in tools_to_activate: for tool in tools_to_activate:
if hasattr(tool, 'activated_env'): if hasattr(tool, 'activated_env'):
(key, value) = parse_key_value(tool.activated_env) envs = tool.activated_environment().split(';')
value = to_native_path(tool.expand_vars(value)) for env in envs:
if not key in os.environ or to_unix_path(os.environ[key]) != to_unix_path(value): # Don't set env. vars which are already set to the correct value. (key, value) = parse_key_value(env)
env_vars_to_add += [(key, value)] value = to_native_path(tool.expand_vars(value))
if not key in os.environ or to_unix_path(os.environ[key]) != to_unix_path(value): # Don't set env. vars which are already set to the correct value.
env_vars_to_add += [(key, value)]
if len(env_vars_to_add) > 0: if len(env_vars_to_add) > 0:
print('Setting environment variables:') print('Setting environment variables:')