Skip to content

Commit a4d4950

Browse files
committed
[nrf fromlist] scripts: parse module.yml for dts bindings
Change BoardYml compliance check from using get_module_setting_root() to load and parse module.yml directly. get_module_setting_root cannot be used directly with module.yml. Instead adjust the code so that the module.yml file is loaded locally and the dts_root setting is extracted from the dictionary. Upstream PR #: 94397 Signed-off-by: Torsten Rasmussen <[email protected]>
1 parent 8bc1683 commit a4d4950

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

scripts/ci/check_compliance.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -345,15 +345,24 @@ def check_board_file(self, file, vendor_prefixes):
345345

346346
def run(self):
347347
path = resolve_path_hint(self.path_hint)
348+
module_ymls = [path / "zephyr" / "module.yml", path / "zephyr" / "module.yaml"]
348349

349350
vendor_prefixes = {"others"}
350351
# add vendor prefixes from the main zephyr repo
351352
vendor_prefixes |= get_vendor_prefixes(ZEPHYR_BASE / "dts" / "bindings" / "vendor-prefixes.txt", self.error)
352-
353353
# add vendor prefixes from the current repo
354-
dts_roots = get_module_setting_root('dts', path / "zephyr" / "module.yml")
355-
for dts_root in dts_roots:
356-
vendor_prefix_file = dts_root / "dts" / "bindings" / "vendor-prefixes.txt"
354+
dts_root = None
355+
for module_yml in module_ymls:
356+
if module_yml.is_file():
357+
with module_yml.open('r', encoding='utf-8') as f:
358+
meta = yaml.load(f.read(), Loader=SafeLoader)
359+
section = meta.get('build', dict())
360+
build_settings = section.get('settings', None)
361+
if build_settings:
362+
dts_root = build_settings.get('dts_root', None)
363+
364+
if dts_root:
365+
vendor_prefix_file = Path(dts_root) / "dts" / "bindings" / "vendor-prefixes.txt"
357366
if vendor_prefix_file.exists():
358367
vendor_prefixes |= get_vendor_prefixes(vendor_prefix_file, self.error)
359368

0 commit comments

Comments
 (0)