Lines 1-201
Link Here
|
1 |
--- configure.py.orig 2011-10-24 19:51:31.000000000 +0000 |
|
|
2 |
+++ configure.py 2011-10-24 19:52:25.000000000 +0000 |
3 |
@@ -58,7 +58,7 @@ |
4 |
self.include_dir = os.path.join(self.build_dir, 'include') |
5 |
self.full_include_dir = os.path.join(self.include_dir, 'botan') |
6 |
|
7 |
- all_files = sum([mod.add for mod in modules], []) |
8 |
+ all_files = sum([list(mod.add) for mod in modules], []) |
9 |
|
10 |
self.headers = sorted( |
11 |
[file for file in all_files if file.endswith('.h')]) |
12 |
@@ -290,7 +290,7 @@ |
13 |
|
14 |
for group in allowed_groups: |
15 |
to_obj.__dict__[group] = [] |
16 |
- for (key,val) in name_val_pairs.iteritems(): |
17 |
+ for (key,val) in list(name_val_pairs.items()): |
18 |
to_obj.__dict__[key] = val |
19 |
|
20 |
def lexed_tokens(): # Convert to an interator |
21 |
@@ -320,7 +320,7 @@ |
22 |
raise LexerError('Group "%s" not terminated' % (group), |
23 |
lexer.lineno) |
24 |
|
25 |
- elif token in name_val_pairs.keys(): |
26 |
+ elif token in list(name_val_pairs.keys()): |
27 |
to_obj.__dict__[token] = lexer.get_token() |
28 |
else: # No match -> error |
29 |
raise LexerError('Bad token "%s"' % (token), lexer.lineno) |
30 |
@@ -329,7 +329,7 @@ |
31 |
Convert a lex'ed map (from build-data files) from a list to a dict |
32 |
""" |
33 |
def force_to_dict(l): |
34 |
- return dict(zip(l[::3],l[2::3])) |
35 |
+ return dict(list(zip(l[::3],l[2::3]))) |
36 |
|
37 |
""" |
38 |
Represents the information about a particular module |
39 |
@@ -361,7 +361,7 @@ |
40 |
return os.path.join(os.path.split(self.lives_in)[0], |
41 |
*filename.split(':')) |
42 |
|
43 |
- self.add = map(add_dir_name, self.add) |
44 |
+ self.add = list(map(add_dir_name, self.add)) |
45 |
|
46 |
self.mp_bits = int(self.mp_bits) |
47 |
|
48 |
@@ -413,8 +413,8 @@ |
49 |
self.unaligned_ok = 0 |
50 |
|
51 |
def all_submodels(self): |
52 |
- return sorted(zip(self.submodels, self.submodels) + |
53 |
- self.submodel_aliases.items(), |
54 |
+ return sorted([(k,k) for k in self.submodels] + |
55 |
+ [k for k in list(self.submodel_aliases.items())], |
56 |
key = lambda k: len(k[0]), reverse = True) |
57 |
|
58 |
def defines(self, target_submodel, with_endian): |
59 |
@@ -574,13 +574,26 @@ |
60 |
for feat in self.target_features] |
61 |
|
62 |
def canon_processor(archinfo, proc): |
63 |
- for ainfo in archinfo.values(): |
64 |
+ # First, try to search for an exact match |
65 |
+ for ainfo in list(archinfo.values()): |
66 |
if ainfo.basename == proc or proc in ainfo.aliases: |
67 |
return (ainfo.basename, ainfo.basename) |
68 |
- else: |
69 |
- for (match,submodel) in ainfo.all_submodels(): |
70 |
- if re.search(match, proc) != None: |
71 |
- return (ainfo.basename, submodel) |
72 |
+ |
73 |
+ for (match,submodel) in ainfo.all_submodels(): |
74 |
+ if proc == submodel: |
75 |
+ return (ainfo.basename, submodel) |
76 |
+ |
77 |
+ # Now, try searching via regex match |
78 |
+ for ainfo in list(archinfo.values()): |
79 |
+ for (match,submodel) in ainfo.all_submodels(): |
80 |
+ if re.search(match, proc) != None: |
81 |
+ return (ainfo.basename, submodel) |
82 |
+ |
83 |
+ logging.debug('Known CPU names: ' + ' '.join( |
84 |
+ sorted(sum([[ainfo.basename] + \ |
85 |
+ ainfo.aliases + \ |
86 |
+ [x for (x,_) in ainfo.all_submodels()] |
87 |
+ for ainfo in list(archinfo.values())], [])))) |
88 |
|
89 |
raise Exception('Unknown or unidentifiable processor "%s"' % (proc)) |
90 |
|
91 |
@@ -597,7 +610,7 @@ |
92 |
if full_proc == '': |
93 |
full_proc = base_proc |
94 |
|
95 |
- for ainfo in archinfo.values(): |
96 |
+ for ainfo in list(archinfo.values()): |
97 |
if ainfo.basename == base_proc or base_proc in ainfo.aliases: |
98 |
for (match,submodel) in ainfo.all_submodels(): |
99 |
if re.search(match, full_proc) != None: |
100 |
@@ -626,7 +639,7 @@ |
101 |
try: |
102 |
template = PercentSignTemplate(slurp_file(template_file)) |
103 |
return template.substitute(variables) |
104 |
- except KeyError, e: |
105 |
+ except KeyError as e: |
106 |
raise Exception('Unbound var %s in template %s' % (e, template_file)) |
107 |
|
108 |
""" |
109 |
@@ -642,7 +655,7 @@ |
110 |
def link_to(): |
111 |
libs = set() |
112 |
for module in modules: |
113 |
- for (osname,link_to) in module.libs.iteritems(): |
114 |
+ for (osname,link_to) in list(module.libs.items()): |
115 |
if osname == 'all' or osname == osinfo.basename: |
116 |
libs.add(link_to) |
117 |
else: |
118 |
@@ -798,8 +811,7 @@ |
119 |
|
120 |
'doc_files': makefile_list(build_config.doc_files()), |
121 |
|
122 |
- 'mod_list': '\n'.join(['%s (%s)' % (m.basename, m.realname) |
123 |
- for m in sorted(modules)]), |
124 |
+ 'mod_list': '\n'.join(sorted([m.basename for m in modules])), |
125 |
} |
126 |
|
127 |
""" |
128 |
@@ -814,7 +826,7 @@ |
129 |
def cannot_use_because(mod, reason): |
130 |
not_using_because.setdefault(reason, []).append(mod) |
131 |
|
132 |
- for (modname, module) in modules.iteritems(): |
133 |
+ for (modname, module) in list(modules.items()): |
134 |
if modname in options.disabled_modules: |
135 |
cannot_use_because(modname, 'disabled by user') |
136 |
elif modname in options.enabled_modules: |
137 |
@@ -862,8 +874,7 @@ |
138 |
while dependency_failure: |
139 |
dependency_failure = False |
140 |
for modname in to_load: |
141 |
- for deplist in map(lambda s: s.split('|'), |
142 |
- modules[modname].dependencies()): |
143 |
+ for deplist in [s.split('|') for s in modules[modname].dependencies()]: |
144 |
|
145 |
dep_met = False |
146 |
for mod in deplist: |
147 |
@@ -1020,7 +1031,7 @@ |
148 |
# First delete the build tree, if existing |
149 |
try: |
150 |
shutil.rmtree(build_config.build_dir) |
151 |
- except OSError, e: |
152 |
+ except OSError as e: |
153 |
logging.debug('Error while removing build dir: %s' % (e)) |
154 |
|
155 |
for dirs in [build_config.checkobj_dir, |
156 |
@@ -1055,7 +1066,7 @@ |
157 |
sink = os.path.join(build_config.build_dir, sink) |
158 |
templates_to_proc[source] = sink |
159 |
|
160 |
- for (template, sink) in templates_to_proc.items(): |
161 |
+ for (template, sink) in list(templates_to_proc.items()): |
162 |
try: |
163 |
f = open(sink, 'w') |
164 |
f.write(process_template(template, template_vars)) |
165 |
@@ -1128,7 +1139,7 @@ |
166 |
if options.os not in osinfo: |
167 |
|
168 |
def find_canonical_os_name(os): |
169 |
- for (name, info) in osinfo.items(): |
170 |
+ for (name, info) in list(osinfo.items()): |
171 |
if os in info.aliases: |
172 |
return name |
173 |
return os # not found |
174 |
@@ -1166,13 +1177,13 @@ |
175 |
matching_version = '(4\.[01234]\.)|(3\.[34]\.)|(2\.95\.[0-4])' |
176 |
|
177 |
gcc_version = ''.join( |
178 |
- subprocess.Popen(['g++', '-v'], |
179 |
+ str(subprocess.Popen(['g++', '-v'], |
180 |
stdout=subprocess.PIPE, |
181 |
- stderr=subprocess.PIPE).communicate()) |
182 |
+ stderr=subprocess.PIPE).communicate())) |
183 |
|
184 |
if re.search(matching_version, gcc_version): |
185 |
options.dumb_gcc = True |
186 |
- except OSError, e: |
187 |
+ except OSError as e: |
188 |
logging.info('Could not execute GCC for version check') |
189 |
|
190 |
if options.dumb_gcc is True: |
191 |
@@ -1206,8 +1217,8 @@ |
192 |
if __name__ == '__main__': |
193 |
try: |
194 |
main() |
195 |
- except Exception, e: |
196 |
- print >>sys.stderr, e |
197 |
+ except Exception as e: |
198 |
+ logging.error(str(e)) |
199 |
#import traceback |
200 |
#traceback.print_exc(file=sys.stderr) |
201 |
sys.exit(1) |