|
5 | 5 |
|
6 | 6 | import argparse
|
7 | 7 | import difflib
|
8 |
| -import itertools |
9 | 8 | import sys
|
10 |
| -from collections import Counter, defaultdict |
| 9 | +from collections import Counter |
11 | 10 | from dataclasses import dataclass, field
|
12 | 11 | from pathlib import Path
|
13 | 12 |
|
@@ -152,81 +151,6 @@ def from_qualifier(self, qualifiers):
|
152 | 151 | return node
|
153 | 152 |
|
154 | 153 |
|
155 |
| -def board_key(board): |
156 |
| - return board.name |
157 |
| - |
158 |
| - |
159 |
| -def find_arch2boards(args): |
160 |
| - arch2board_set = find_arch2board_set(args) |
161 |
| - return {arch: sorted(arch2board_set[arch], key=board_key) |
162 |
| - for arch in arch2board_set} |
163 |
| - |
164 |
| - |
165 |
| -def find_boards(args): |
166 |
| - return sorted(itertools.chain(*find_arch2board_set(args).values()), |
167 |
| - key=board_key) |
168 |
| - |
169 |
| - |
170 |
| -def find_arch2board_set(args): |
171 |
| - arches = sorted(find_arches(args)) |
172 |
| - ret = defaultdict(set) |
173 |
| - |
174 |
| - for root in unique_paths(args.board_roots): |
175 |
| - for arch, boards in find_arch2board_set_in(root, arches, args.board_dir).items(): |
176 |
| - if args.board is not None: |
177 |
| - ret[arch] |= {b for b in boards if b.name == args.board} |
178 |
| - else: |
179 |
| - ret[arch] |= boards |
180 |
| - |
181 |
| - return ret |
182 |
| - |
183 |
| - |
184 |
| -def find_arches(args): |
185 |
| - arch_set = set() |
186 |
| - |
187 |
| - for root in unique_paths(args.arch_roots): |
188 |
| - arch_set |= find_arches_in(root) |
189 |
| - |
190 |
| - return arch_set |
191 |
| - |
192 |
| - |
193 |
| -def find_arches_in(root): |
194 |
| - ret = set() |
195 |
| - arch = root / 'arch' |
196 |
| - common = arch / 'common' |
197 |
| - |
198 |
| - if not arch.is_dir(): |
199 |
| - return ret |
200 |
| - |
201 |
| - for maybe_arch in arch.iterdir(): |
202 |
| - if not maybe_arch.is_dir() or maybe_arch == common: |
203 |
| - continue |
204 |
| - ret.add(maybe_arch.name) |
205 |
| - |
206 |
| - return ret |
207 |
| - |
208 |
| - |
209 |
| -def find_arch2board_set_in(root, arches, board_dir): |
210 |
| - ret = defaultdict(set) |
211 |
| - boards = root / 'boards' |
212 |
| - |
213 |
| - for arch in arches: |
214 |
| - if not (boards / arch).is_dir(): |
215 |
| - continue |
216 |
| - for maybe_board in (boards / arch).iterdir(): |
217 |
| - if not maybe_board.is_dir(): |
218 |
| - continue |
219 |
| - if board_dir and maybe_board not in board_dir: |
220 |
| - continue |
221 |
| - for maybe_defconfig in maybe_board.iterdir(): |
222 |
| - file_name = maybe_defconfig.name |
223 |
| - if file_name.endswith('_defconfig') and not (maybe_board / BOARD_YML).is_file(): |
224 |
| - board_name = file_name[:-len('_defconfig')] |
225 |
| - ret[arch].add(Board(board_name, maybe_board, 'v1', arch=arch)) |
226 |
| - |
227 |
| - return ret |
228 |
| - |
229 |
| - |
230 | 154 | def load_v2_boards(board_name, board_yml, systems):
|
231 | 155 | boards = {}
|
232 | 156 | board_extensions = []
|
@@ -426,37 +350,6 @@ def notfound(x):
|
426 | 350 | print(f'{b.name}')
|
427 | 351 |
|
428 | 352 |
|
429 |
| -def dump_boards(args): |
430 |
| - arch2boards = find_arch2boards(args) |
431 |
| - for arch, boards in arch2boards.items(): |
432 |
| - if args.fuzzy_match is not None: |
433 |
| - close_boards = difflib.get_close_matches(args.fuzzy_match, [b.name for b in boards]) |
434 |
| - if not close_boards: |
435 |
| - continue |
436 |
| - boards = [b for b in boards if b.name in close_boards] |
437 |
| - if args.cmakeformat is None: |
438 |
| - print(f'{arch}:') |
439 |
| - for board in boards: |
440 |
| - if args.cmakeformat is not None: |
441 |
| - info = args.cmakeformat.format( |
442 |
| - NAME='NAME;' + board.name, |
443 |
| - DIR='DIR;' + str(board.dir.as_posix()), |
444 |
| - HWM='HWM;' + board.hwm, |
445 |
| - VENDOR='VENDOR;NOTFOUND', |
446 |
| - REVISION_DEFAULT='REVISION_DEFAULT;NOTFOUND', |
447 |
| - REVISION_FORMAT='REVISION_FORMAT;NOTFOUND', |
448 |
| - REVISION_EXACT='REVISION_EXACT;NOTFOUND', |
449 |
| - REVISIONS='REVISIONS;NOTFOUND', |
450 |
| - VARIANT_DEFAULT='VARIANT_DEFAULT;NOTFOUND', |
451 |
| - SOCS='SOCS;', |
452 |
| - QUALIFIERS='QUALIFIERS;' |
453 |
| - ) |
454 |
| - print(info) |
455 |
| - else: |
456 |
| - print(f' {board.name}') |
457 |
| - |
458 |
| - |
459 | 353 | if __name__ == '__main__':
|
460 | 354 | args = parse_args()
|
461 |
| - dump_boards(args) |
462 | 355 | dump_v2_boards(args)
|
0 commit comments