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.
|
The free-form description of the binding.
|
||||||
|
|
||||||
compatible:
|
compatible:
|
||||||
The compatible string the binding matches. This is None if the Binding is
|
The compatible string the binding matches.
|
||||||
inferred from node properties. If the Binding is a child binding, then
|
|
||||||
this will be inherited from the parent binding unless the child binding
|
This may be None. For example, it's None when the Binding is inferred
|
||||||
explicitly sets its own compatible.
|
from node properties. It can also be None for Binding objects created
|
||||||
|
using 'child-binding:' with no compatible.
|
||||||
|
|
||||||
prop2specs:
|
prop2specs:
|
||||||
A collections.OrderedDict mapping property names to PropertySpec objects
|
A collections.OrderedDict mapping property names to PropertySpec objects
|
||||||
|
@ -1564,14 +1565,6 @@ class Binding:
|
||||||
if key.endswith("-cells"):
|
if key.endswith("-cells"):
|
||||||
self.specifier2cells[key[:-len("-cells")]] = val
|
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):
|
def __repr__(self):
|
||||||
if self.compatible:
|
if self.compatible:
|
||||||
compat = f" for compatible '{self.compatible}'"
|
compat = f" for compatible '{self.compatible}'"
|
||||||
|
@ -1587,15 +1580,8 @@ class Binding:
|
||||||
@property
|
@property
|
||||||
def compatible(self):
|
def compatible(self):
|
||||||
"See the class docstring"
|
"See the class docstring"
|
||||||
if hasattr(self, '_compatible'):
|
|
||||||
return self._compatible
|
|
||||||
return self.raw.get('compatible')
|
return self.raw.get('compatible')
|
||||||
|
|
||||||
@compatible.setter
|
|
||||||
def compatible(self, compatible):
|
|
||||||
"See the class docstring"
|
|
||||||
self._compatible = compatible
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def bus(self):
|
def bus(self):
|
||||||
"See the class docstring"
|
"See the class docstring"
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
description: child-binding with separate compatible than the parent
|
description: child-binding with separate compatible than the parent
|
||||||
|
|
||||||
compatible: "child-binding-with-compat"
|
compatible: "top-binding-with-compat"
|
||||||
|
|
||||||
child-binding:
|
child-binding:
|
||||||
compatible: child-compat
|
compatible: child-compat
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
description: child-binding test
|
description: child-binding test
|
||||||
|
|
||||||
compatible: "child-binding"
|
compatible: "top-binding"
|
||||||
|
|
||||||
child-binding:
|
child-binding:
|
||||||
description: child node
|
description: child node
|
||||||
|
|
|
@ -359,7 +359,7 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
child-binding {
|
child-binding {
|
||||||
compatible = "child-binding";
|
compatible = "top-binding";
|
||||||
child-1 {
|
child-1 {
|
||||||
child-prop = <1>;
|
child-prop = <1>;
|
||||||
grandchild {
|
grandchild {
|
||||||
|
|
|
@ -181,15 +181,15 @@ def test_child_binding():
|
||||||
child = top.child_binding
|
child = top.child_binding
|
||||||
assert Path(top.path) == binding_file
|
assert Path(top.path) == binding_file
|
||||||
assert Path(child.path) == binding_file
|
assert Path(child.path) == binding_file
|
||||||
assert top.compatible == 'child-binding'
|
assert top.compatible == 'top-binding'
|
||||||
assert child.compatible == 'child-binding'
|
assert child.compatible is None
|
||||||
|
|
||||||
binding_file = Path("test-bindings/child-binding-with-compat.yaml").resolve()
|
binding_file = Path("test-bindings/child-binding-with-compat.yaml").resolve()
|
||||||
top = edtlib.Binding(binding_file, {})
|
top = edtlib.Binding(binding_file, {})
|
||||||
child = top.child_binding
|
child = top.child_binding
|
||||||
assert Path(top.path) == binding_file
|
assert Path(top.path) == binding_file
|
||||||
assert Path(child.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'
|
assert child.compatible == 'child-compat'
|
||||||
|
|
||||||
def test_props():
|
def test_props():
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue