aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2017-12-03 13:34:04 -0500
committerJack Lloyd <[email protected]>2017-12-03 13:34:04 -0500
commit788fd2bacb19fcf630c7857a10c72ec4067b50f6 (patch)
treea3c1630c98256c5ca5d7a2678525b849fa820883
parentcb063792ae7fb1d267b3d6861ba8e4adfe072054 (diff)
Avoid code duplication in configure
parse_lex_dict is force_to_dict + error checking.
-rwxr-xr-xconfigure.py23
1 files changed, 6 insertions, 17 deletions
diff --git a/configure.py b/configure.py
index cda6a9019..ee26d0320 100755
--- a/configure.py
+++ b/configure.py
@@ -638,8 +638,7 @@ class LexerError(InternalError):
def parse_lex_dict(as_list):
if len(as_list) % 3 != 0:
- raise InternalError(
- "Lex dictionary has invalid format (input not divisible by 3): %s" % as_list)
+ raise InternalError("Lex dictionary has invalid format (input not divisible by 3): %s" % as_list)
result = {}
for key, sep, value in [as_list[3*i:3*i+3] for i in range(0, len(as_list)//3)]:
@@ -707,16 +706,6 @@ def lex_me_harder(infofile, allowed_groups, name_val_pairs):
return out
-
-def force_to_dict(l):
- """
- Convert a lex'ed map (from build-data files) from a list to a dict
- TODO: Add error checking of input...
- """
-
- return dict(zip(l[::3], l[2::3]))
-
-
class InfoObject(object):
def __init__(self, infofile):
"""
@@ -999,7 +988,7 @@ class ArchInfo(InfoObject):
self.family = lex.family
self.isa_extensions = lex.isa_extensions
self.submodels = lex.submodels
- self.submodel_aliases = force_to_dict(lex.submodel_aliases)
+ self.submodel_aliases = parse_lex_dict(lex.submodel_aliases)
self.wordsize = int(lex.wordsize)
def all_submodels(self):
@@ -1105,15 +1094,15 @@ class CompilerInfo(InfoObject): # pylint: disable=too-many-instance-attributes
self.ar_command = lex.ar_command
self.ar_options = lex.ar_options
self.ar_output_to = lex.ar_output_to
- self.binary_link_commands = force_to_dict(lex.binary_link_commands)
+ self.binary_link_commands = parse_lex_dict(lex.binary_link_commands)
self.binary_name = lex.binary_name
self.compile_flags = lex.compile_flags
self.coverage_flags = lex.coverage_flags
self.debug_info_flags = lex.debug_info_flags
- self.isa_flags = force_to_dict(lex.isa_flags)
+ self.isa_flags = parse_lex_dict(lex.isa_flags)
self.lang_flags = lex.lang_flags
self.linker_name = lex.linker_name
- self.mach_abi_linking = force_to_dict(lex.mach_abi_linking)
+ self.mach_abi_linking = parse_lex_dict(lex.mach_abi_linking)
self.macro_name = lex.macro_name
self.maintainer_warning_flags = lex.maintainer_warning_flags
self.optimization_flags = lex.optimization_flags
@@ -1122,7 +1111,7 @@ class CompilerInfo(InfoObject): # pylint: disable=too-many-instance-attributes
self.sanitizer_flags = lex.sanitizer_flags
self.shared_flags = lex.shared_flags
self.size_optimization_flags = lex.size_optimization_flags
- self.so_link_commands = force_to_dict(lex.so_link_commands)
+ self.so_link_commands = parse_lex_dict(lex.so_link_commands)
self.stack_protector_flags = lex.stack_protector_flags
self.visibility_build_flags = lex.visibility_build_flags
self.visibility_attribute = lex.visibility_attribute