diff mbox series

[v2,09/28] binman: Use 'files-compress' to set compression for files

Message ID 20201026234026.1903778-9-sjg@chromium.org
State Accepted
Commit 9248c8d9c9674d705216e51161c1f0f473fc7fa3
Delegated to: Simon Glass
Headers show
Series binman: Support compression of sections | expand

Commit Message

Simon Glass Oct. 26, 2020, 11:40 p.m. UTC
At present we use 'compress' as the property to set the compression of
a 'files' entry. But this conflicts with the same property for entries,
of which Entry_section is a subclass.

Strictly speaking, since Entry_files is in fact a subclass of
Entry_section, the files can be compressed individually but also the
section (that contains all the files) can itself be compressed. With this
change, it is possible to express that.

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

(no changes since v1)

 tools/binman/README.entries              | 2 +-
 tools/binman/etype/files.py              | 7 ++++---
 tools/binman/etype/section.py            | 4 ++--
 tools/binman/test/085_files_compress.dts | 2 +-
 4 files changed, 8 insertions(+), 7 deletions(-)

Comments

Simon Glass Oct. 30, 2020, 3:34 a.m. UTC | #1
At present we use 'compress' as the property to set the compression of
a 'files' entry. But this conflicts with the same property for entries,
of which Entry_section is a subclass.

Strictly speaking, since Entry_files is in fact a subclass of
Entry_section, the files can be compressed individually but also the
section (that contains all the files) can itself be compressed. With this
change, it is possible to express that.

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

(no changes since v1)

 tools/binman/README.entries              | 2 +-
 tools/binman/etype/files.py              | 7 ++++---
 tools/binman/etype/section.py            | 4 ++--
 tools/binman/test/085_files_compress.dts | 2 +-
 4 files changed, 8 insertions(+), 7 deletions(-)

Applied to u-boot-dm, thanks!
diff mbox series

Patch

diff --git a/tools/binman/README.entries b/tools/binman/README.entries
index 13b930d5186..999b77690f0 100644
--- a/tools/binman/README.entries
+++ b/tools/binman/README.entries
@@ -299,7 +299,7 @@  Entry: files: Entry containing a set of files
 
 Properties / Entry arguments:
     - pattern: Filename pattern to match the files to include
-    - compress: Compression algorithm to use:
+    - files-compress: Compression algorithm to use:
         none: No compression
         lz4: Use lz4 compression (via 'lz4' command-line utility)
 
diff --git a/tools/binman/etype/files.py b/tools/binman/etype/files.py
index 9adb3afeb14..ce3832e3cdd 100644
--- a/tools/binman/etype/files.py
+++ b/tools/binman/etype/files.py
@@ -19,7 +19,7 @@  class Entry_files(Entry_section):
 
     Properties / Entry arguments:
         - pattern: Filename pattern to match the files to include
-        - compress: Compression algorithm to use:
+        - files-compress: Compression algorithm to use:
             none: No compression
             lz4: Use lz4 compression (via 'lz4' command-line utility)
 
@@ -36,7 +36,8 @@  class Entry_files(Entry_section):
         self._pattern = fdt_util.GetString(self._node, 'pattern')
         if not self._pattern:
             self.Raise("Missing 'pattern' property")
-        self._compress = fdt_util.GetString(self._node, 'compress', 'none')
+        self._files_compress = fdt_util.GetString(self._node, 'files-compress',
+                                                  'none')
         self._require_matches = fdt_util.GetBool(self._node,
                                                 'require-matches')
 
@@ -53,7 +54,7 @@  class Entry_files(Entry_section):
                 subnode = state.AddSubnode(self._node, name)
             state.AddString(subnode, 'type', 'blob')
             state.AddString(subnode, 'filename', fname)
-            state.AddString(subnode, 'compress', self._compress)
+            state.AddString(subnode, 'compress', self._files_compress)
 
         # Read entries again, now that we have some
         self._ReadEntries()
diff --git a/tools/binman/etype/section.py b/tools/binman/etype/section.py
index a3e37c33c1b..9222042f5d8 100644
--- a/tools/binman/etype/section.py
+++ b/tools/binman/etype/section.py
@@ -160,7 +160,7 @@  class Entry_section(Entry):
                 section_data += tools.GetBytes(self._pad_byte, pad)
         self.Detail('GetData: %d entries, total size %#x' %
                     (len(self._entries), len(section_data)))
-        return section_data
+        return self.CompressData(section_data)
 
     def GetOffsets(self):
         """Handle entries that want to set the offset/size of other entries
@@ -414,7 +414,7 @@  class Entry_section(Entry):
         return None
 
     def GetEntryContents(self):
-        """Call ObtainContents() for the section
+        """Call ObtainContents() for each entry in the section
         """
         todo = self._entries.values()
         for passnum in range(3):
diff --git a/tools/binman/test/085_files_compress.dts b/tools/binman/test/085_files_compress.dts
index 847b398bf2b..5aeead2e6e9 100644
--- a/tools/binman/test/085_files_compress.dts
+++ b/tools/binman/test/085_files_compress.dts
@@ -5,7 +5,7 @@ 
 	binman {
 		files {
 			pattern = "files/*.dat";
-			compress = "lz4";
+			files-compress = "lz4";
 		};
 	};
 };