Skip to content

Commit 304363b

Browse files
committed
scripts: list_boards: add fast path for --board flag
Speed up the execution time of find_v2_boards() if the board name is already known and avoid call to rglob. This change both reduces memory used and also IO activity on the file system. On my machine I see the execution time drop from ~1.6 seconds to ~0.5 seconds. When sysbuild is enabled, the time savings are doubled. Signed-off-by: Guðni Már Gilbert <[email protected]>
1 parent c44cb73 commit 304363b

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

scripts/list_boards.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,21 @@ def find_v2_boards(args):
315315
board_files = []
316316
if args.board_dir:
317317
board_files = [d / BOARD_YML for d in args.board_dir]
318-
else:
318+
elif args.board:
319+
# Fast path for HWMv2: boards/<vendor>/<board>/board.yml
320+
for root in unique_paths(args.board_roots):
321+
boards_root = root / 'boards'
322+
if not boards_root.is_dir():
323+
continue
324+
for vendor_dir in boards_root.iterdir(): # boards/<vendor>
325+
if not vendor_dir.is_dir():
326+
continue
327+
board_yml = vendor_dir / args.board / BOARD_YML
328+
if board_yml.is_file():
329+
board_files.append(board_yml)
330+
break
331+
332+
if not board_files:
319333
for root in unique_paths(args.board_roots):
320334
board_files.extend((root / 'boards').rglob(BOARD_YML))
321335

0 commit comments

Comments
 (0)