scripts: Ignore duplicate roots in list_boards/hardware
When iterating over `--arch-root`, `--board-root`, and `--soc-root`, treat them as collections of absolute paths with no repeats, to ensure that no input root has to be handled more than once. Signed-off-by: Grzegorz Swiderski <grzegorz.swiderski@nordicsemi.no>
This commit is contained in:
parent
4acb615c14
commit
9dabce43d2
|
@ -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:
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Reference in a new issue