edtlib: only do compatible checks once
Remember the compatibles we've validated, and don't check them again. Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
This commit is contained in:
parent
2a241f6ef9
commit
4a313129b2
1 changed files with 17 additions and 6 deletions
|
@ -72,6 +72,7 @@ from copy import deepcopy
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
from typing import Set
|
||||||
|
|
||||||
import yaml
|
import yaml
|
||||||
try:
|
try:
|
||||||
|
@ -476,8 +477,7 @@ class EDT:
|
||||||
', '.join(repr(x) for x in spec.enum))
|
', '.join(repr(x) for x in spec.enum))
|
||||||
|
|
||||||
# Validate the contents of compatible properties.
|
# Validate the contents of compatible properties.
|
||||||
# The regular expression comes from dt-schema.
|
self._checked_compatibles: Set[str] = set()
|
||||||
compat_re = r'^[a-zA-Z][a-zA-Z0-9,+\-._]+$'
|
|
||||||
for node in self.nodes:
|
for node in self.nodes:
|
||||||
if 'compatible' not in node.props:
|
if 'compatible' not in node.props:
|
||||||
continue
|
continue
|
||||||
|
@ -494,10 +494,21 @@ class EDT:
|
||||||
# This is also just for future-proofing.
|
# This is also just for future-proofing.
|
||||||
assert isinstance(compat, str)
|
assert isinstance(compat, str)
|
||||||
|
|
||||||
if not re.match(compat_re, compat):
|
self._check_compatible(node, compat)
|
||||||
_err(f"node '{node.path}' compatible '{compat}' "
|
del self._checked_compatibles # We have no need for this anymore.
|
||||||
'must match this regular expression: '
|
|
||||||
f"'{compat_re}'")
|
def _check_compatible(self, node, compat):
|
||||||
|
if compat in self._checked_compatibles:
|
||||||
|
return
|
||||||
|
|
||||||
|
# The regular expression comes from dt-schema.
|
||||||
|
compat_re = r'^[a-zA-Z][a-zA-Z0-9,+\-._]+$'
|
||||||
|
if not re.match(compat_re, compat):
|
||||||
|
_err(f"node '{node.path}' compatible '{compat}' "
|
||||||
|
'must match this regular expression: '
|
||||||
|
f"'{compat_re}'")
|
||||||
|
|
||||||
|
self._checked_compatibles.add(compat)
|
||||||
|
|
||||||
class Node:
|
class Node:
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue