Asset Packer: Enforce LF when packing --nobuild

This commit is contained in:
Willy-JL
2024-10-27 04:21:54 +00:00
parent 2788ae14a6
commit 3f1b181c53
+7 -3
View File
@@ -1,4 +1,4 @@
#!/usr/bin/env python
# https://github.com/Next-Flip/Momentum-Firmware/blob/dev/scripts/asset_packer.py
from PIL import Image, ImageOps
import heatshrink2
import pathlib
@@ -45,6 +45,10 @@ def convert_bmx(img: "Image.Image | pathlib.Path") -> bytes:
return data
def copy_file_as_lf(src: "pathlib.Path", dst: "pathlib.Path"):
dst.write_bytes(src.read_bytes().replace(b"\r\n", b"\n"))
def pack_anim(src: pathlib.Path, dst: pathlib.Path):
if not (src / "meta.txt").is_file():
return
@@ -53,7 +57,7 @@ def pack_anim(src: pathlib.Path, dst: pathlib.Path):
if not frame.is_file():
continue
if frame.name == "meta.txt":
shutil.copyfile(frame, dst / frame.name)
copy_file_as_lf(frame, dst / frame.name)
elif frame.name.startswith("frame_"):
if frame.suffix == ".png":
(dst / frame.with_suffix(".bm").name).write_bytes(convert_bm(frame))
@@ -145,7 +149,7 @@ def pack(
if (source / "Anims/manifest.txt").exists():
(packed / "Anims").mkdir(parents=True, exist_ok=True)
shutil.copyfile(
copy_file_as_lf(
source / "Anims/manifest.txt", packed / "Anims/manifest.txt"
)
manifest = (source / "Anims/manifest.txt").read_bytes()