All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Glass <sjg@chromium.org>
To: u-boot@lists.denx.de
Subject: [PATCH v3 04/12] binman: Move 'external' support into base class
Date: Tue,  1 Sep 2020 05:13:57 -0600	[thread overview]
Message-ID: <20200901051400.v3.4.Ic50628d181bb5ddb1f8b8dd6fa56769bff927a18@changeid> (raw)
In-Reply-To: <20200901111405.358391-1-sjg@chromium.org>

At present we have an Entry_blob_ext which implement a blob which holds an
external binary. We need to support other entry types that hold external
binaries, e.g. Entry_blob_named_by_arg. Move the support into the base
Entry class to allow this.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

(no changes since v2)

Changes in v2:
- Add new patch to move 'external' support into base class

 tools/binman/README.entries    |  2 +-
 tools/binman/entry.py          | 14 ++++++++++++++
 tools/binman/etype/blob.py     |  8 +++++++-
 tools/binman/etype/blob_ext.py | 11 -----------
 tools/binman/etype/section.py  | 14 ++------------
 5 files changed, 24 insertions(+), 25 deletions(-)

diff --git a/tools/binman/README.entries b/tools/binman/README.entries
index 97bfae16116..1086a6a9790 100644
--- a/tools/binman/README.entries
+++ b/tools/binman/README.entries
@@ -692,7 +692,7 @@ Properties / Entry arguments: (see binman README for more information)
         when writing out the map
 
 Properties:
-    _allow_missing: True if this section permits external blobs to be
+    allow_missing: True if this section permits external blobs to be
         missing their contents. The second will produce an image but of
         course it will not work.
 
diff --git a/tools/binman/entry.py b/tools/binman/entry.py
index c17a98958bd..0f128c4cf5e 100644
--- a/tools/binman/entry.py
+++ b/tools/binman/entry.py
@@ -57,6 +57,10 @@ class Entry(object):
         compress: Compression algoithm used (e.g. 'lz4'), 'none' if none
         orig_offset: Original offset value read from node
         orig_size: Original size value read from node
+        missing: True if this entry is missing its contents
+        allow_missing: Allow children of this entry to be missing (used by
+            subclasses such as Entry_section)
+        external: True if this entry contains an external binary blob
     """
     def __init__(self, section, etype, node, name_prefix=''):
         # Put this here to allow entry-docs and help to work without libfdt
@@ -83,6 +87,8 @@ class Entry(object):
         self._expand_size = False
         self.compress = 'none'
         self.missing = False
+        self.external = False
+        self.allow_missing = False
 
     @staticmethod
     def Lookup(node_path, etype):
@@ -813,3 +819,11 @@ features to produce new behaviours.
         """
         if self.missing:
             missing_list.append(self)
+
+    def GetAllowMissing(self):
+        """Get whether a section allows missing external blobs
+
+        Returns:
+            True if allowed, False if not allowed
+        """
+        return self.allow_missing
diff --git a/tools/binman/etype/blob.py b/tools/binman/etype/blob.py
index e507203709f..c5f97c85a38 100644
--- a/tools/binman/etype/blob.py
+++ b/tools/binman/etype/blob.py
@@ -37,7 +37,13 @@ class Entry_blob(Entry):
 
     def ObtainContents(self):
         self._filename = self.GetDefaultFilename()
-        self._pathname = tools.GetInputFilename(self._filename)
+        self._pathname = tools.GetInputFilename(self._filename,
+                                                self.section.GetAllowMissing())
+        # Allow the file to be missing
+        if self.external and not self._pathname:
+            self.SetContents(b'')
+            self.missing = True
+            return True
         self.ReadBlobContents()
         return True
 
diff --git a/tools/binman/etype/blob_ext.py b/tools/binman/etype/blob_ext.py
index 8d641001a9e..e372445f300 100644
--- a/tools/binman/etype/blob_ext.py
+++ b/tools/binman/etype/blob_ext.py
@@ -26,14 +26,3 @@ class Entry_blob_ext(Entry_blob):
     def __init__(self, section, etype, node):
         Entry_blob.__init__(self, section, etype, node)
         self.external = True
-
-    def ObtainContents(self):
-        self._filename = self.GetDefaultFilename()
-        self._pathname = tools.GetInputFilename(self._filename,
-                                                self.section.GetAllowMissing())
-        # Allow the file to be missing
-        if not self._pathname:
-            self.SetContents(b'')
-            self.missing = True
-            return True
-        return super().ObtainContents()
diff --git a/tools/binman/etype/section.py b/tools/binman/etype/section.py
index 72600b1ef3a..515c97f9290 100644
--- a/tools/binman/etype/section.py
+++ b/tools/binman/etype/section.py
@@ -35,7 +35,7 @@ class Entry_section(Entry):
             when writing out the map
 
     Properties:
-        _allow_missing: True if this section permits external blobs to be
+        allow_missing: True if this section permits external blobs to be
             missing their contents. The second will produce an image but of
             course it will not work.
 
@@ -54,8 +54,6 @@ class Entry_section(Entry):
         self._sort = False
         self._skip_at_start = None
         self._end_4gb = False
-        self._allow_missing = False
-        self.missing = False
 
     def ReadNode(self):
         """Read properties from the image node"""
@@ -549,18 +547,10 @@ class Entry_section(Entry):
         Args:
             allow_missing: True if allowed, False if not allowed
         """
-        self._allow_missing = allow_missing
+        self.allow_missing = allow_missing
         for entry in self._entries.values():
             entry.SetAllowMissing(allow_missing)
 
-    def GetAllowMissing(self):
-        """Get whether a section allows missing external blobs
-
-        Returns:
-            True if allowed, False if not allowed
-        """
-        return self._allow_missing
-
     def CheckMissing(self, missing_list):
         """Check if any entries in this section have missing external blobs
 
-- 
2.28.0.402.g5ffc5be6b7-goog

  parent reply	other threads:[~2020-09-01 11:13 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-01 11:13 [PATCH v3 00/12] binman: Add support for generating more complex FITs Simon Glass
2020-09-01 11:13 ` [PATCH v3 01/12] binman: Allow entry args to be required Simon Glass
2020-09-01 11:13 ` [PATCH v3 02/12] binman: Fix up a few missing comments Simon Glass
2020-09-01 11:13 ` [PATCH v3 03/12] libfdt: Detected out-of-space with fdt_finish() Simon Glass
2020-09-01 11:13 ` Simon Glass [this message]
2020-09-01 11:13 ` [PATCH v3 05/12] binman: Add support for ATF BL31 Simon Glass
2020-09-05 22:57   ` Samuel Holland
2020-09-06  0:17     ` Simon Glass
2020-09-01 11:13 ` [PATCH v3 06/12] binman: Support generating FITs with multiple dtbs Simon Glass
2020-09-05 22:41   ` Samuel Holland
2020-09-05 23:19     ` Samuel Holland
2020-09-06  0:17       ` Simon Glass
2020-09-06  0:18     ` Simon Glass
2020-09-01 11:14 ` [PATCH v3 07/12] Makefile: Support missing external blobs always Simon Glass
2020-09-01 11:14 ` [PATCH v3 08/12] sunxi: Convert 64-bit boards to use binman Simon Glass
2020-09-05 23:10   ` Samuel Holland
2020-09-05 23:42     ` Samuel Holland
2020-09-06  0:17       ` Simon Glass
2020-09-06  0:18     ` Simon Glass
2020-09-06  1:49       ` Samuel Holland
2020-09-06  2:22         ` Simon Glass
2020-09-07 13:01       ` Michal Simek
2020-09-07 13:57         ` Simon Glass
2020-09-01 11:14 ` [PATCH v3 09/12] sunxi: Drop the FIT-generator script Simon Glass
2020-09-01 11:14 ` [PATCH v3 10/12] binman: Allow selecting default FIT configuration Simon Glass
2020-09-01 11:14 ` [PATCH v3 11/12] binman: Support help messages for missing blobs Simon Glass
2020-09-01 11:14 ` [PATCH v3 12/12] binman: sunxi: Add help message for missing sunxi ATF BL31 Simon Glass
2020-09-02 10:26 ` [PATCH v3 00/12] binman: Add support for generating more complex FITs Michal Simek
2020-09-02 17:07   ` Simon Glass
2020-09-03 13:31     ` Michal Simek
2020-09-05 21:10 ` [PATCH v3 07/12] Makefile: Support missing external blobs always Simon Glass
2020-09-05 21:10 ` [PATCH v3 06/12] binman: Support generating FITs with multiple dtbs Simon Glass
2020-09-05 21:10 ` [PATCH v3 05/12] binman: Add support for ATF BL31 Simon Glass
2020-09-05 21:10 ` [PATCH v3 04/12] binman: Move 'external' support into base class Simon Glass
2020-09-05 21:10 ` [PATCH v3 03/12] libfdt: Detected out-of-space with fdt_finish() Simon Glass
2020-09-05 21:10 ` [PATCH v3 02/12] binman: Fix up a few missing comments Simon Glass
2020-09-05 21:10 ` [PATCH v3 01/12] binman: Allow entry args to be required Simon Glass
2020-09-07  6:31   ` Michal Simek
2020-09-07 13:57     ` Simon Glass

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200901051400.v3.4.Ic50628d181bb5ddb1f8b8dd6fa56769bff927a18@changeid \
    --to=sjg@chromium.org \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.