|
|
@ -1,4 +1,4 @@
|
|
|
|
import os
|
|
|
|
import os, shutil
|
|
|
|
|
|
|
|
|
|
|
|
RES_DIR = "../res/"
|
|
|
|
RES_DIR = "../res/"
|
|
|
|
PACKED_DIR = "../include/packed/"
|
|
|
|
PACKED_DIR = "../include/packed/"
|
|
|
@ -7,11 +7,22 @@ resources = os.fsencode(RES_DIR)
|
|
|
|
os.makedirs(PACKED_DIR, exist_ok=True)
|
|
|
|
os.makedirs(PACKED_DIR, exist_ok=True)
|
|
|
|
packed_dir = os.fsencode(PACKED_DIR)
|
|
|
|
packed_dir = os.fsencode(PACKED_DIR)
|
|
|
|
|
|
|
|
|
|
|
|
for file in os.listdir(packed_dir):
|
|
|
|
for filename in os.listdir(packed_dir):
|
|
|
|
if os.path.splitext(file)[1] == b".hpp":
|
|
|
|
file_path = os.path.join(packed_dir, filename)
|
|
|
|
os.unlink(os.path.join(packed_dir, file))
|
|
|
|
if os.path.isfile(file_path) or os.path.islink(file_path):
|
|
|
|
|
|
|
|
os.unlink(file_path)
|
|
|
|
|
|
|
|
elif os.path.isdir(file_path):
|
|
|
|
|
|
|
|
shutil.rmtree(file_path)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for folder in os.listdir(resources):
|
|
|
|
|
|
|
|
folder_path = os.path.join(resources, folder)
|
|
|
|
|
|
|
|
if os.path.isfile(folder_path):
|
|
|
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
packed_path = os.path.join(packed_dir, folder)
|
|
|
|
|
|
|
|
os.makedirs(packed_path, exist_ok=True)
|
|
|
|
|
|
|
|
for resource in os.listdir(folder_path):
|
|
|
|
|
|
|
|
resource_path = os.path.join(folder_path, resource)
|
|
|
|
|
|
|
|
|
|
|
|
for resource in os.listdir(resources):
|
|
|
|
|
|
|
|
res = ""
|
|
|
|
res = ""
|
|
|
|
|
|
|
|
|
|
|
|
splitext = os.path.splitext(resource)
|
|
|
|
splitext = os.path.splitext(resource)
|
|
|
@ -25,7 +36,7 @@ for resource in os.listdir(resources):
|
|
|
|
name += "_data"
|
|
|
|
name += "_data"
|
|
|
|
|
|
|
|
|
|
|
|
encoded = f"const unsigned char {name.upper()}[] = {'{'}"
|
|
|
|
encoded = f"const unsigned char {name.upper()}[] = {'{'}"
|
|
|
|
file = open(os.path.join(resources, resource), "rb") # read binary
|
|
|
|
file = open(resource_path, "rb") # read binary
|
|
|
|
bytes_processed = 0
|
|
|
|
bytes_processed = 0
|
|
|
|
for byte in file.read():
|
|
|
|
for byte in file.read():
|
|
|
|
if bytes_processed % 16 == 0:
|
|
|
|
if bytes_processed % 16 == 0:
|
|
|
@ -34,5 +45,5 @@ for resource in os.listdir(resources):
|
|
|
|
bytes_processed += 1
|
|
|
|
bytes_processed += 1
|
|
|
|
encoded = encoded[:-2] + "\n};"
|
|
|
|
encoded = encoded[:-2] + "\n};"
|
|
|
|
res += encoded + "\n"
|
|
|
|
res += encoded + "\n"
|
|
|
|
with open(os.path.join(PACKED_DIR, f"{name}.hpp"), "w") as f:
|
|
|
|
with open(os.path.join(packed_path.decode(), f"{name}.hpp"), "w") as f:
|
|
|
|
f.write(res)
|
|
|
|
f.write(res)
|