Refactor such that Tool.activated_config returns a map. NFC (#502)

Split out from #501
This commit is contained in:
Sam Clegg
2020-05-13 18:43:00 -04:00
committed by GitHub
parent 4265173445
commit 7e22ab8ae0

View File

@@ -1461,10 +1461,7 @@ def generate_dot_emscripten(active_tools):
# activated is the relevant one. # activated is the relevant one.
activated_config = OrderedDict() activated_config = OrderedDict()
for tool in active_tools: for tool in active_tools:
tool_cfg = tool.activated_config() for name, value in tool.activated_config().items():
if tool_cfg:
for specific_cfg in tool_cfg.split(';'):
name, value = specific_cfg.split('=')
activated_config[name] = value activated_config[name] = value
if 'NODE_JS' not in activated_config: if 'NODE_JS' not in activated_config:
@@ -1474,7 +1471,7 @@ def generate_dot_emscripten(active_tools):
activated_config['NODE_JS'] = "'%s'" % node_fallback activated_config['NODE_JS'] = "'%s'" % node_fallback
for name, value in activated_config.items(): for name, value in activated_config.items():
cfg += name + ' = ' + value + '\n' cfg += name + " = '" + value + "'\n"
cfg += '''\ cfg += '''\
TEMP_DIR = '%s' TEMP_DIR = '%s'
@@ -1620,10 +1617,14 @@ class Tool(object):
# Returns the configuration item that needs to be added to .emscripten to make # Returns the configuration item that needs to be added to .emscripten to make
# this Tool active for the current user. # this Tool active for the current user.
def activated_config(self): def activated_config(self):
if hasattr(self, 'activated_cfg'): if not hasattr(self, 'activated_cfg'):
return to_unix_path(self.expand_vars(self.activated_cfg)) return {}
else: config = OrderedDict()
return '' expanded = to_unix_path(self.expand_vars(self.activated_cfg))
for specific_cfg in expanded.split(';'):
name, value = specific_cfg.split('=')
config[name] = value.strip("'")
return config
def activated_environment(self): def activated_environment(self):
if hasattr(self, 'activated_env'): if hasattr(self, 'activated_env'):
@@ -1727,13 +1728,10 @@ class Tool(object):
return False return False
activated_cfg = self.activated_config() activated_cfg = self.activated_config()
if activated_cfg == '': if not activated_cfg:
return len(deps) > 0 return len(deps) > 0
activated_cfg = activated_cfg.split(';') for key, value in activated_cfg.items():
for cfg in activated_cfg:
cfg = cfg.strip()
key, value = parse_key_value(cfg)
if key not in dot_emscripten: if key not in dot_emscripten:
debug_print(str(self) + ' is not active, because key="' + key + '" does not exist in .emscripten') debug_print(str(self) + ' is not active, because key="' + key + '" does not exist in .emscripten')
return False return False
@@ -1741,6 +1739,7 @@ class Tool(object):
# If running in embedded mode, all paths are stored dynamically relative # If running in embedded mode, all paths are stored dynamically relative
# to the emsdk root, so normalize those first. # to the emsdk root, so normalize those first.
dot_emscripten_key = dot_emscripten[key].replace("emsdk_path + '", "'" + emsdk_path()) dot_emscripten_key = dot_emscripten[key].replace("emsdk_path + '", "'" + emsdk_path())
dot_emscripten_key = dot_emscripten_key.strip("'")
if dot_emscripten_key != value: if dot_emscripten_key != value:
debug_print(str(self) + ' is not active, because key="' + key + '" has value "' + dot_emscripten_key + '" but should have value "' + value + '"') debug_print(str(self) + ' is not active, because key="' + key + '" has value "' + dot_emscripten_key + '" but should have value "' + value + '"')
return False return False