import struct
import sys
-from binman import comp_util
+from binman import bintool
from binman import elf
from patman import command
from patman import tools
self.data_len = len(data)
self.erase_byte = None
self.size = None
+ if self.compress == COMPRESS_LZ4:
+ self.comp_bintool = bintool.Bintool.create('lz4')
+ elif self.compress == COMPRESS_LZMA:
+ self.comp_bintool = bintool.Bintool.create('lzma_alone')
+ else:
+ self.comp_bintool = None
def decompress(self):
"""Handle decompressing data if necessary"""
indata = self.data
- if self.compress == COMPRESS_LZ4:
- data = comp_util.decompress(indata, 'lz4')
- elif self.compress == COMPRESS_LZMA:
- data = comp_util.decompress(indata, 'lzma')
+ if self.comp_bintool:
+ data = self.comp_bintool.decompress(indata)
else:
data = indata
self.memlen = len(data)
data = elf_data.data
elif self.ftype == TYPE_RAW:
orig_data = data
- if self.compress == COMPRESS_LZ4:
- data = comp_util.compress(orig_data, 'lz4')
- elif self.compress == COMPRESS_LZMA:
- data = comp_util.compress(orig_data, 'lzma')
+ if self.comp_bintool:
+ data = self.comp_bintool.compress(orig_data)
self.memlen = len(orig_data)
self.data_len = len(data)
attr = struct.pack(ATTR_COMPRESSION_FORMAT,
from binman import bintool
from binman import cbfs_util
from binman.cbfs_util import CbfsWriter
-from binman import comp_util
from binman import elf
from patman import test_util
from patman import tools
cls.cbfstool = bintool.Bintool.create('cbfstool')
cls.have_cbfstool = cls.cbfstool.is_present()
- cls.have_lz4 = comp_util.HAVE_LZ4
+ lz4 = bintool.Bintool.create('lz4')
+ cls.have_lz4 = lz4.is_present()
@classmethod
def tearDownClass(cls):