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:
Luca Burelli 2025-05-29 10:05:10 +02:00 committed by Daniel DeGrasse
commit ed7f2e0833

View file

@ -179,9 +179,10 @@ class Node:
def _get_prop(self, name: str) -> 'Property':
# 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:
prop = Property(self, name)
self.props[name] = prop