* Impl. sectioned font table in firmware * make_translation.py: Extract build_symbol_conversion_table function * Put translation indices and strings in a struct * Move translation objcopy step to Python * Impl. multi-language firmware demo * Impl. strings-compressed multi-lang firmware demo * Add font compression to multi-lang demo * Refactor Makefile a bit * Fix rules for make < 4.3 * Add more multi-lang groups * Add Pinecil multi-lang CI build * Add lzfx compression license text * Remote multi-language demo group * Fix build after merge * Import code from BriefLZ * Change brieflz for our use case * Change compression to use brieflz * Remove lzfx code * Update license file for brieflz * Exclude brieflz files from format check * Add BriefLZ test
26 lines
601 B
Python
26 lines
601 B
Python
import os
|
|
import subprocess
|
|
import tempfile
|
|
|
|
|
|
if "OBJCOPY" in os.environ:
|
|
OBJCOPY = os.environ["OBJCOPY"]
|
|
else:
|
|
OBJCOPY = "objcopy"
|
|
|
|
|
|
def get_binary_from_obj(objfile_path: str, section_name: str) -> bytes:
|
|
tmpfd, tmpfile = tempfile.mkstemp()
|
|
result = subprocess.run(
|
|
[OBJCOPY, "-O", "binary", "-j", section_name, objfile_path, tmpfile]
|
|
)
|
|
result.check_returncode()
|
|
with open(tmpfd, "rb") as f:
|
|
bin: bytes = f.read()
|
|
os.remove(tmpfile)
|
|
return bin
|
|
|
|
|
|
def cpp_var_to_section_name(var_name: str) -> str:
|
|
return f".rodata._ZL{len(var_name)}{var_name}"
|