|
|
|
@ -38,12 +38,14 @@ def embed_file(out, f, idx, embedded_name, uncompressed):
@@ -38,12 +38,14 @@ def embed_file(out, f, idx, embedded_name, uncompressed):
|
|
|
|
|
|
|
|
|
|
compressed = tempfile.NamedTemporaryFile() |
|
|
|
|
if uncompressed: |
|
|
|
|
compressed.write(open(f,'rb').read()) |
|
|
|
|
# ensure nul termination |
|
|
|
|
if sys.version_info[0] >= 3: |
|
|
|
|
compressed.write(bytearray(0)) |
|
|
|
|
nul = bytearray(0) |
|
|
|
|
else: |
|
|
|
|
compressed.write(chr(0)) |
|
|
|
|
nul = chr(0) |
|
|
|
|
if contents[-1] != nul: |
|
|
|
|
contents += nul |
|
|
|
|
compressed.write(contents) |
|
|
|
|
else: |
|
|
|
|
# compress it |
|
|
|
|
f = open(compressed.name, "wb") |
|
|
|
@ -66,6 +68,9 @@ def create_embedded_h(filename, files, uncompressed=False):
@@ -66,6 +68,9 @@ def create_embedded_h(filename, files, uncompressed=False):
|
|
|
|
|
out = open(filename, "wb") |
|
|
|
|
write_encode(out, '''// generated embedded files for AP_ROMFS\n\n''') |
|
|
|
|
|
|
|
|
|
# remove duplicates and sort |
|
|
|
|
files = sorted(list(set(files))) |
|
|
|
|
|
|
|
|
|
for i in range(len(files)): |
|
|
|
|
(name, filename) = files[i] |
|
|
|
|
if not embed_file(out, filename, i, name, uncompressed): |
|
|
|
|