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):
|
def activated_environment(self):
|
||||||
if hasattr(self, 'activated_env'):
|
if hasattr(self, 'activated_env'):
|
||||||
return self.expand_vars(self.activated_env)
|
return self.expand_vars(self.activated_env).split(';')
|
||||||
else:
|
else:
|
||||||
return ''
|
return []
|
||||||
|
|
||||||
def compatible_with_this_os(self):
|
def compatible_with_this_os(self):
|
||||||
if hasattr(self, 'os'):
|
if hasattr(self, 'os'):
|
||||||
@@ -1269,13 +1269,12 @@ 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'):
|
envs = self.activated_environment()
|
||||||
envs = self.activated_environment().split(';')
|
for env in envs:
|
||||||
for env in envs:
|
(key, value) = parse_key_value(env)
|
||||||
(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 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('\\', '/')
|
||||||
@@ -1288,8 +1287,8 @@ class Tool:
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
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:
|
||||||
envs = self.activated_environment().split(';')
|
envs = self.activated_environment()
|
||||||
for env in envs:
|
for env in envs:
|
||||||
(key, value) = parse_key_value(env)
|
(key, value) = parse_key_value(env)
|
||||||
|
|
||||||
@@ -1956,13 +1955,12 @@ def construct_env(tools_to_activate, permanent):
|
|||||||
mkdir_p(em_cache_dir)
|
mkdir_p(em_cache_dir)
|
||||||
|
|
||||||
for tool in tools_to_activate:
|
for tool in tools_to_activate:
|
||||||
if hasattr(tool, 'activated_env'):
|
envs = tool.activated_environment()
|
||||||
envs = tool.activated_environment().split(';')
|
for env in envs:
|
||||||
for env in envs:
|
(key, value) = parse_key_value(env)
|
||||||
(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)]
|
|
||||||
|
|
||||||
if len(env_vars_to_add) > 0:
|
if len(env_vars_to_add) > 0:
|
||||||
print('Setting environment variables:')
|
print('Setting environment variables:')
|
||||||
|
|||||||
Reference in New Issue
Block a user