From 3f1b181c5326dd154f67df0c027f610190e9c3c5 Mon Sep 17 00:00:00 2001 From: Willy-JL <49810075+Willy-JL@users.noreply.github.com> Date: Sun, 27 Oct 2024 04:21:54 +0000 Subject: [PATCH] Asset Packer: Enforce LF when packing --nobuild --- scripts/asset_packer.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/scripts/asset_packer.py b/scripts/asset_packer.py index dcfa68f8e..095b89970 100755 --- a/scripts/asset_packer.py +++ b/scripts/asset_packer.py @@ -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()