scripts: edtlib: do not inherit parent compatibles
Commit 0d4dca10b2
("scripts: edtlib:
child binding compatibles match parents") was a hack meant to keep the
edtlib.Binding class in place without modifying some twister behavior
that needed further changes to work properly with first-class binding
objects.
This is a hack and is no longer necessary, so back out of this change.
Child Binding objects now have None compatible properties unless the
binding YAML explicitly sets a compatible.
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
This commit is contained in:
parent
963b1666f3
commit
f5409dec01
5 changed files with 11 additions and 25 deletions
|
@ -1454,10 +1454,11 @@ class Binding:
|
|||
The free-form description of the binding.
|
||||
|
||||
compatible:
|
||||
The compatible string the binding matches. This is None if the Binding is
|
||||
inferred from node properties. If the Binding is a child binding, then
|
||||
this will be inherited from the parent binding unless the child binding
|
||||
explicitly sets its own compatible.
|
||||
The compatible string the binding matches.
|
||||
|
||||
This may be None. For example, it's None when the Binding is inferred
|
||||
from node properties. It can also be None for Binding objects created
|
||||
using 'child-binding:' with no compatible.
|
||||
|
||||
prop2specs:
|
||||
A collections.OrderedDict mapping property names to PropertySpec objects
|
||||
|
@ -1564,14 +1565,6 @@ class Binding:
|
|||
if key.endswith("-cells"):
|
||||
self.specifier2cells[key[:-len("-cells")]] = val
|
||||
|
||||
# Make child binding compatibles match ours if they are missing.
|
||||
if self.compatible is not None:
|
||||
child = self.child_binding
|
||||
while child is not None:
|
||||
if child.compatible is None:
|
||||
child.compatible = self.compatible
|
||||
child = child.child_binding
|
||||
|
||||
def __repr__(self):
|
||||
if self.compatible:
|
||||
compat = f" for compatible '{self.compatible}'"
|
||||
|
@ -1587,15 +1580,8 @@ class Binding:
|
|||
@property
|
||||
def compatible(self):
|
||||
"See the class docstring"
|
||||
if hasattr(self, '_compatible'):
|
||||
return self._compatible
|
||||
return self.raw.get('compatible')
|
||||
|
||||
@compatible.setter
|
||||
def compatible(self, compatible):
|
||||
"See the class docstring"
|
||||
self._compatible = compatible
|
||||
|
||||
@property
|
||||
def bus(self):
|
||||
"See the class docstring"
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
description: child-binding with separate compatible than the parent
|
||||
|
||||
compatible: "child-binding-with-compat"
|
||||
compatible: "top-binding-with-compat"
|
||||
|
||||
child-binding:
|
||||
compatible: child-compat
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
description: child-binding test
|
||||
|
||||
compatible: "child-binding"
|
||||
compatible: "top-binding"
|
||||
|
||||
child-binding:
|
||||
description: child node
|
||||
|
|
|
@ -359,7 +359,7 @@
|
|||
//
|
||||
|
||||
child-binding {
|
||||
compatible = "child-binding";
|
||||
compatible = "top-binding";
|
||||
child-1 {
|
||||
child-prop = <1>;
|
||||
grandchild {
|
||||
|
|
|
@ -181,15 +181,15 @@ def test_child_binding():
|
|||
child = top.child_binding
|
||||
assert Path(top.path) == binding_file
|
||||
assert Path(child.path) == binding_file
|
||||
assert top.compatible == 'child-binding'
|
||||
assert child.compatible == 'child-binding'
|
||||
assert top.compatible == 'top-binding'
|
||||
assert child.compatible is None
|
||||
|
||||
binding_file = Path("test-bindings/child-binding-with-compat.yaml").resolve()
|
||||
top = edtlib.Binding(binding_file, {})
|
||||
child = top.child_binding
|
||||
assert Path(top.path) == binding_file
|
||||
assert Path(child.path) == binding_file
|
||||
assert top.compatible == 'child-binding-with-compat'
|
||||
assert top.compatible == 'top-binding-with-compat'
|
||||
assert child.compatible == 'child-compat'
|
||||
|
||||
def test_props():
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue