mirror of
https://github.com/u-boot/u-boot.git
synced 2025-04-19 19:34:35 +00:00
binman: Allow text directly in the node
At present text entries use an indirect method to specify the text to use, with a label pointing to the text itself. Allow the text to be directly written into the node. This is more convenient in cases where the text is constant. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
cf54904a99
commit
aa88b50d82
4 changed files with 34 additions and 5 deletions
|
@ -312,6 +312,8 @@ Properties / Entry arguments:
|
||||||
that contains the string to place in the entry
|
that contains the string to place in the entry
|
||||||
<xxx> (actual name is the value of text-label): contains the string to
|
<xxx> (actual name is the value of text-label): contains the string to
|
||||||
place in the entry.
|
place in the entry.
|
||||||
|
<text>: The text to place in the entry (overrides the above mechanism).
|
||||||
|
This is useful when the text is constant.
|
||||||
|
|
||||||
Example node:
|
Example node:
|
||||||
|
|
||||||
|
@ -334,6 +336,13 @@ It is also possible to put the string directly in the node:
|
||||||
message = "a message directly in the node"
|
message = "a message directly in the node"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
or just:
|
||||||
|
|
||||||
|
text {
|
||||||
|
size = <8>;
|
||||||
|
text = "some text directly in the node"
|
||||||
|
};
|
||||||
|
|
||||||
The text is not itself nul-terminated. This can be achieved, if required,
|
The text is not itself nul-terminated. This can be achieved, if required,
|
||||||
by setting the size of the entry to something larger than the text.
|
by setting the size of the entry to something larger than the text.
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,8 @@ class Entry_text(Entry):
|
||||||
that contains the string to place in the entry
|
that contains the string to place in the entry
|
||||||
<xxx> (actual name is the value of text-label): contains the string to
|
<xxx> (actual name is the value of text-label): contains the string to
|
||||||
place in the entry.
|
place in the entry.
|
||||||
|
<text>: The text to place in the entry (overrides the above mechanism).
|
||||||
|
This is useful when the text is constant.
|
||||||
|
|
||||||
Example node:
|
Example node:
|
||||||
|
|
||||||
|
@ -44,15 +46,28 @@ class Entry_text(Entry):
|
||||||
message = "a message directly in the node"
|
message = "a message directly in the node"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
or just:
|
||||||
|
|
||||||
|
text {
|
||||||
|
size = <8>;
|
||||||
|
text = "some text directly in the node"
|
||||||
|
};
|
||||||
|
|
||||||
The text is not itself nul-terminated. This can be achieved, if required,
|
The text is not itself nul-terminated. This can be achieved, if required,
|
||||||
by setting the size of the entry to something larger than the text.
|
by setting the size of the entry to something larger than the text.
|
||||||
"""
|
"""
|
||||||
def __init__(self, section, etype, node):
|
def __init__(self, section, etype, node):
|
||||||
Entry.__init__(self, section, etype, node)
|
Entry.__init__(self, section, etype, node)
|
||||||
label, = self.GetEntryArgsOrProps([EntryArg('text-label', str)])
|
value = fdt_util.GetString(self._node, 'text')
|
||||||
self.text_label = tools.ToStr(label) if type(label) != str else label
|
if value:
|
||||||
value, = self.GetEntryArgsOrProps([EntryArg(self.text_label, str)])
|
value = tools.ToBytes(value)
|
||||||
value = tools.ToBytes(value) if value is not None else value
|
else:
|
||||||
|
label, = self.GetEntryArgsOrProps([EntryArg('text-label', str)])
|
||||||
|
self.text_label = label
|
||||||
|
if self.text_label:
|
||||||
|
value, = self.GetEntryArgsOrProps([EntryArg(self.text_label,
|
||||||
|
str)])
|
||||||
|
value = tools.ToBytes(value) if value is not None else value
|
||||||
self.value = value
|
self.value = value
|
||||||
|
|
||||||
def ObtainContents(self):
|
def ObtainContents(self):
|
||||||
|
|
|
@ -1286,7 +1286,7 @@ class TestFunctional(unittest.TestCase):
|
||||||
expected = (tools.ToBytes(TEXT_DATA) +
|
expected = (tools.ToBytes(TEXT_DATA) +
|
||||||
tools.GetBytes(0, 8 - len(TEXT_DATA)) +
|
tools.GetBytes(0, 8 - len(TEXT_DATA)) +
|
||||||
tools.ToBytes(TEXT_DATA2) + tools.ToBytes(TEXT_DATA3) +
|
tools.ToBytes(TEXT_DATA2) + tools.ToBytes(TEXT_DATA3) +
|
||||||
b'some text')
|
b'some text' + b'more text')
|
||||||
self.assertEqual(expected, data)
|
self.assertEqual(expected, data)
|
||||||
|
|
||||||
def testEntryDocs(self):
|
def testEntryDocs(self):
|
||||||
|
|
|
@ -24,5 +24,10 @@
|
||||||
text-label = "test-id4";
|
text-label = "test-id4";
|
||||||
test-id4 = "some text";
|
test-id4 = "some text";
|
||||||
};
|
};
|
||||||
|
/* Put text directly in the node */
|
||||||
|
text5 {
|
||||||
|
type = "text";
|
||||||
|
text = "more text";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue