diff --git a/scripts/list_boards.py b/scripts/list_boards.py index 5321f31b0b..597ecf9180 100755 --- a/scripts/list_boards.py +++ b/scripts/list_boards.py @@ -13,6 +13,7 @@ import sys from typing import List import yaml import list_hardware +from list_hardware import unique_paths BOARD_SCHEMA_PATH = str(Path(__file__).parent / 'schemas' / 'board-schema.yml') with open(BOARD_SCHEMA_PATH, 'r') as f: @@ -116,7 +117,7 @@ def find_arch2board_set(args): arches = sorted(find_arches(args)) ret = defaultdict(set) - for root in args.board_roots: + for root in unique_paths(args.board_roots): for arch, boards in find_arch2board_set_in(root, arches, args.board_dir).items(): if args.board is not None: ret[arch] |= {b for b in boards if b.name == args.board} @@ -129,7 +130,7 @@ def find_arch2board_set(args): def find_arches(args): arch_set = set() - for root in args.arch_roots: + for root in unique_paths(args.arch_roots): arch_set |= find_arches_in(root) return arch_set @@ -236,7 +237,7 @@ def find_v2_boards(args): boards = [] board_files = [] - for root in args.board_roots: + for root in unique_paths(args.board_roots): board_files.extend((root / 'boards').rglob(BOARD_YML)) for board_yml in board_files: diff --git a/scripts/list_hardware.py b/scripts/list_hardware.py index e17ff7b453..2fa7c2a363 100755 --- a/scripts/list_hardware.py +++ b/scripts/list_hardware.py @@ -141,9 +141,14 @@ class Family: socs: List[Soc] +def unique_paths(paths): + # Using dict keys ensures both uniqueness and a deterministic order. + yield from dict.fromkeys(map(Path.resolve, paths)).keys() + + def find_v2_archs(args): ret = {'archs': []} - for root in args.arch_roots: + for root in unique_paths(args.arch_roots): archs_yml = root / ARCHS_YML_PATH if Path(archs_yml).is_file(): @@ -172,7 +177,7 @@ def find_v2_archs(args): def find_v2_systems(args): yml_files = [] systems = Systems() - for root in args.soc_roots: + for root in unique_paths(args.soc_roots): yml_files.extend(sorted((root / 'soc').rglob(SOC_YML))) for soc_yml in yml_files: