scripts: dts: dtlib: preserve order of properties in DTS output
Ensure that the order of properties in the output DTS file matches the order in which they are defined in the DTS source files by moving props to the end of the dictionary when they are accessed. Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
This commit is contained in:
parent
0a4e2e383f
commit
ed7f2e0833
1 changed files with 4 additions and 3 deletions
|
@ -179,12 +179,13 @@ class Node:
|
||||||
|
|
||||||
def _get_prop(self, name: str) -> 'Property':
|
def _get_prop(self, name: str) -> 'Property':
|
||||||
# Returns the property named 'name' on the node, creating it if it
|
# Returns the property named 'name' on the node, creating it if it
|
||||||
# doesn't already exist
|
# doesn't already exist. Move the entry to the end of the props
|
||||||
|
# dictionary so the order is preserved in the output DTS file.
|
||||||
|
|
||||||
prop = self.props.get(name)
|
prop = self.props.pop(name, None)
|
||||||
if not prop:
|
if not prop:
|
||||||
prop = Property(self, name)
|
prop = Property(self, name)
|
||||||
self.props[name] = prop
|
self.props[name] = prop
|
||||||
return prop
|
return prop
|
||||||
|
|
||||||
def _del(self) -> None:
|
def _del(self) -> None:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue