Use Python lz4 module for LZ4
To make SBL scripts/tools more OS-agnostic the lz4 (de)compression module can be used instead of relying on the BaseTools LZ4 package/executable. Need to update the azure pipeline to install the python lz4 module before running the builds. TEST=Confirmed that the python lz4.block.compress routine is compatible with Lz4DecompressLib during SBL runtime to decompress LZ4 binaries. Signed-off-by: James Gutbub <james.gutbub@intel.com>
This commit is contained in:
parent
99fe66faf8
commit
ab49d6c9a0
|
@ -44,6 +44,7 @@ jobs:
|
||||||
displayName: Install required tools
|
displayName: Install required tools
|
||||||
|
|
||||||
- script: |
|
- script: |
|
||||||
|
python -m pip install lz4
|
||||||
python BuildLoader.py build qemu -k
|
python BuildLoader.py build qemu -k
|
||||||
displayName: 'Run QEMU build'
|
displayName: 'Run QEMU build'
|
||||||
|
|
||||||
|
@ -98,6 +99,7 @@ jobs:
|
||||||
displayName: Install required tools
|
displayName: Install required tools
|
||||||
|
|
||||||
- script: |
|
- script: |
|
||||||
|
python -m pip install lz4
|
||||||
python BuildLoader.py build $(Build.Name) $(Build.Arch) $(Build.Target) -k
|
python BuildLoader.py build $(Build.Name) $(Build.Arch) $(Build.Target) -k
|
||||||
displayName: 'Run $(Build.Name) build'
|
displayName: 'Run $(Build.Name) build'
|
||||||
|
|
||||||
|
@ -166,6 +168,7 @@ jobs:
|
||||||
displayName: Environment configuration
|
displayName: Environment configuration
|
||||||
|
|
||||||
- script: |
|
- script: |
|
||||||
|
python -m pip install lz4
|
||||||
python BuildLoader.py build $(Build.Name) $(Build.Arch) $(Build.Target) -k
|
python BuildLoader.py build $(Build.Name) $(Build.Arch) $(Build.Target) -k
|
||||||
displayName: 'Run $(Build.Name) build'
|
displayName: 'Run $(Build.Name) build'
|
||||||
|
|
||||||
|
|
|
@ -340,6 +340,17 @@ def decompress (in_file, out_file, tool_dir = ''):
|
||||||
fo.write(di[offset:offset + lz_hdr.compressed_len])
|
fo.write(di[offset:offset + lz_hdr.compressed_len])
|
||||||
fo.close()
|
fo.close()
|
||||||
|
|
||||||
|
if alg == "Lz4":
|
||||||
|
try:
|
||||||
|
import lz4.block
|
||||||
|
except ImportError:
|
||||||
|
print("Could not import lz4, use 'python -m pip install lz4' to install it.")
|
||||||
|
exit(1)
|
||||||
|
decompress_data = lz4.block.decompress(get_file_data(temp))
|
||||||
|
with open(out_file, "wb") as lz4bin:
|
||||||
|
lz4bin.write(decompress_data)
|
||||||
|
lz4bin.close()
|
||||||
|
else:
|
||||||
compress_tool = "%sCompress" % alg
|
compress_tool = "%sCompress" % alg
|
||||||
cmdline = [
|
cmdline = [
|
||||||
os.path.join (tool_dir, compress_tool),
|
os.path.join (tool_dir, compress_tool),
|
||||||
|
@ -377,7 +388,15 @@ def compress (in_file, alg, svn=0, out_path = '', tool_dir = ''):
|
||||||
if in_len > 0:
|
if in_len > 0:
|
||||||
if sig == "LZDM":
|
if sig == "LZDM":
|
||||||
shutil.copy(in_file, out_file)
|
shutil.copy(in_file, out_file)
|
||||||
else:
|
compress_data = get_file_data(out_file)
|
||||||
|
elif sig == "LZ4 ":
|
||||||
|
try:
|
||||||
|
import lz4.block
|
||||||
|
except ImportError:
|
||||||
|
print("Could not import lz4, use 'python -m pip install lz4' to install it.")
|
||||||
|
exit(1)
|
||||||
|
compress_data = lz4.block.compress(get_file_data(in_file), mode='high_compression')
|
||||||
|
elif sig == "LZMA":
|
||||||
compress_tool = "%sCompress" % alg
|
compress_tool = "%sCompress" % alg
|
||||||
cmdline = [
|
cmdline = [
|
||||||
os.path.join (tool_dir, compress_tool),
|
os.path.join (tool_dir, compress_tool),
|
||||||
|
|
Loading…
Reference in New Issue