mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-07-23 01:18:12 -07:00
Asset Packer: Enforce LF when packing --nobuild
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user