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>
diff --git a/scripts/list_hardware.py b/scripts/list_hardware.py
index e17ff7b..2fa7c2a 100755
--- a/scripts/list_hardware.py
+++ b/scripts/list_hardware.py
@@ -141,9 +141,14 @@
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_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: