Remove redundant checking for hasattr(self, 'activated_env') since activated_environment() function already does that. Also change activated_environment() to return a pre-split list instead of a string that caller is expected to split.
This commit is contained in:
34
emsdk
34
emsdk
@@ -1171,9 +1171,9 @@ class Tool:
|
||||
|
||||
def activated_environment(self):
|
||||
if hasattr(self, 'activated_env'):
|
||||
return self.expand_vars(self.activated_env)
|
||||
return self.expand_vars(self.activated_env).split(';')
|
||||
else:
|
||||
return ''
|
||||
return []
|
||||
|
||||
def compatible_with_this_os(self):
|
||||
if hasattr(self, 'os'):
|
||||
@@ -1269,13 +1269,12 @@ class Tool:
|
||||
|
||||
# Returns true if the system environment variables requires by this tool are currently active.
|
||||
def is_env_active(self):
|
||||
if hasattr(self, 'activated_env'):
|
||||
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 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
|
||||
envs = self.activated_environment()
|
||||
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 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
|
||||
|
||||
if hasattr(self, 'activated_path'):
|
||||
path = self.expand_vars(self.activated_path).replace('\\', '/')
|
||||
@@ -1288,8 +1287,8 @@ class Tool:
|
||||
return True
|
||||
|
||||
def win_activate_env_vars(self, permanently_activate):
|
||||
if WINDOWS and hasattr(self, 'activated_env'):
|
||||
envs = self.activated_environment().split(';')
|
||||
if WINDOWS:
|
||||
envs = self.activated_environment()
|
||||
for env in envs:
|
||||
(key, value) = parse_key_value(env)
|
||||
|
||||
@@ -1956,13 +1955,12 @@ def construct_env(tools_to_activate, permanent):
|
||||
mkdir_p(em_cache_dir)
|
||||
|
||||
for tool in tools_to_activate:
|
||||
if hasattr(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))
|
||||
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)]
|
||||
envs = tool.activated_environment()
|
||||
for env in envs:
|
||||
(key, value) = parse_key_value(env)
|
||||
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:
|
||||
print('Setting environment variables:')
|
||||
|
||||
Reference in New Issue
Block a user