Merge tag 'u-boot-rockchip-20200501' of https://gitlab.denx.de/u-boot/custodians...
[platform/kernel/u-boot.git] / tools / binman / etype / blob_named_by_arg.py
1 # SPDX-License-Identifier: GPL-2.0+
2 # Copyright (c) 2018 Google, Inc
3 # Written by Simon Glass <sjg@chromium.org>
4 #
5 # Entry-type module for a blob where the filename comes from a property in the
6 # node or an entry argument. The property is called '<blob_fname>-path' where
7 # <blob_fname> is provided by the subclass using this entry type.
8
9 from collections import OrderedDict
10
11 from binman.etype.blob import Entry_blob
12 from binman.entry import EntryArg
13
14
15 class Entry_blob_named_by_arg(Entry_blob):
16     """A blob entry which gets its filename property from its subclass
17
18     Properties / Entry arguments:
19         - <xxx>-path: Filename containing the contents of this entry (optional,
20             defaults to 0)
21
22     where <xxx> is the blob_fname argument to the constructor.
23
24     This entry cannot be used directly. Instead, it is used as a parent class
25     for another entry, which defined blob_fname. This parameter is used to
26     set the entry-arg or property containing the filename. The entry-arg or
27     property is in turn used to set the actual filename.
28
29     See cros_ec_rw for an example of this.
30     """
31     def __init__(self, section, etype, node, blob_fname):
32         Entry_blob.__init__(self, section, etype, node)
33         self._filename, = self.GetEntryArgsOrProps(
34             [EntryArg('%s-path' % blob_fname, str)])