binman: Add support for adding a name prefix to entries
Sometimes we have several sections which repeat the same entries (e.g. for
a read-only and read-write version of the same section). It is useful to
be able to tell these entries apart by name.
Add a new 'name-prefix' property for sections, which causes all entries
within that section to have a given name prefix.
Signed-off-by: Simon Glass <sjg@chromium.org>
diff --git a/tools/binman/entry.py b/tools/binman/entry.py
index 3811d33..e4d688c 100644
--- a/tools/binman/entry.py
+++ b/tools/binman/entry.py
@@ -48,11 +48,11 @@
pad_after: Number of pad bytes after the contents, 0 if none
data: Contents of entry (string of bytes)
"""
- def __init__(self, section, etype, node, read_node=True):
+ def __init__(self, section, etype, node, read_node=True, name_prefix=''):
self.section = section
self.etype = etype
self._node = node
- self.name = node and node.name or 'none'
+ self.name = node and (name_prefix + node.name) or 'none'
self.pos = None
self.size = None
self.contents_size = 0
@@ -129,6 +129,15 @@
self.align_end = fdt_util.GetInt(self._node, 'align-end')
self.pos_unset = fdt_util.GetBool(self._node, 'pos-unset')
+ def SetPrefix(self, prefix):
+ """Set the name prefix for a node
+
+ Args:
+ prefix: Prefix to set, or '' to not use a prefix
+ """
+ if prefix:
+ self.name = prefix + self.name
+
def ObtainContents(self):
"""Figure out the contents of an entry.