Add support for multiple environment items to be present in activated_env, separated by semicolon ;.
This commit is contained in:
18
emsdk
18
emsdk
@@ -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(';')
|
||||||
|
for env in envs:
|
||||||
|
(key, value) = parse_key_value(env)
|
||||||
if not key in os.environ or to_unix_path(os.environ[key]) != to_unix_path(value):
|
if not key in os.environ or to_unix_path(os.environ[key]) != to_unix_path(value):
|
||||||
if VERBOSE: print(str(self) + ' is not active, because environment variable key="' + key + '" has value "' + str(os.getenv(key)) + '" but should have value "' + value + '"')
|
if VERBOSE: print(str(self) + ' is not active, because environment variable key="' + key + '" has value "' + str(os.getenv(key)) + '" but should have value "' + value + '"')
|
||||||
return False
|
return False
|
||||||
# if WINDOWS:
|
|
||||||
# env_var = win_get_active_environment_variable(key)
|
|
||||||
# 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,7 +1289,10 @@ 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(';')
|
||||||
|
for env in envs:
|
||||||
|
(key, value) = parse_key_value(env)
|
||||||
|
|
||||||
if 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_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.
|
||||||
|
|
||||||
@@ -1955,7 +1957,9 @@ 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(';')
|
||||||
|
for env in envs:
|
||||||
|
(key, value) = parse_key_value(env)
|
||||||
value = to_native_path(tool.expand_vars(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.
|
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)]
|
env_vars_to_add += [(key, value)]
|
||||||
|
|||||||
Reference in New Issue
Block a user