This commit is contained in:
2025-08-21 13:43:42 +08:00
parent 84ffd021a2
commit eb20c59347
6 changed files with 162 additions and 3 deletions

17
embed.py Normal file
View File

@@ -0,0 +1,17 @@
# embed.py
def file_to_c_array(filename, var_name):
try:
with open(filename, 'rb') as f:
data = f.read()
hex_str = ', '.join(f'0x{b:02x}' for b in data)
return f'// Resource: {filename}\nconst unsigned char {var_name}[] = {{ {hex_str} }};\nconst int {var_name}_len = {len(data)};\n\n'
except FileNotFoundError:
print(f"ERROR: File not found: {filename}")
exit(1)
with open('embedded.h', 'w', encoding='utf-8') as f:
f.write(file_to_c_array('init.py', 'script_main'))
f.write(file_to_c_array('data.db.zip', 'data_zip'))
f.write(file_to_c_array('cyzg.zip', 'cyzg_zip'))
print("done")