papermario/tools/build/bin_inc_c.py
Ethan Roseman 7cb1790789
Fix alignment of many data sections (#305)
* generate c includes for img segments

* flatten battle/item/dusty_hammer.c

needs custom splat

* use .inc.c for c incbins

* fixy

* new stuff

* git subrepo pull (merge) --force tools/splat

subrepo:
  subdir:   "tools/splat"
  merged:   "6120d18600"
upstream:
  origin:   "https://github.com/ethteck/splat.git"
  branch:   "master"
  commit:   "6120d18600"
git-subrepo:
  version:  "0.4.3"
  origin:   "https://github.com/ingydotnet/git-subrepo"
  commit:   "2f68596"

* remove dumb

* git subrepo pull tools/splat

subrepo:
  subdir:   "tools/splat"
  merged:   "8a179e74ba"
upstream:
  origin:   "https://github.com/ethteck/splat.git"
  branch:   "master"
  commit:   "8a179e74ba"
git-subrepo:
  version:  "0.4.3"
  origin:   "https://github.com/ingydotnet/git-subrepo"
  commit:   "2f68596"

* yaml cleaning

* Further yaml cleanup & battle item refactor

* remove rawptr

* git subrepo pull tools/splat

subrepo:
  subdir:   "tools/splat"
  merged:   "fe30b60b75"
upstream:
  origin:   "https://github.com/ethteck/splat.git"
  branch:   "master"
  commit:   "fe30b60b75"
git-subrepo:
  version:  "0.4.3"
  origin:   "https://github.com/ingydotnet/git-subrepo"
  commit:   "2f68596"

* further cleanup

* Further cleanup & match gfx_draw_background

* clean & wip

Co-authored-by: Alex Bates <hi@imalex.xyz>
2021-07-12 18:15:00 +09:00

26 lines
568 B
Python

#! /usr/bin/python3
from sys import argv
import re
import png
if __name__ == "__main__":
infile, outfile = argv[1:]
cname = re.sub(r"[^0-9a-zA-Z_]", "_", outfile)
if cname.startswith("ver_"):
cname = "_".join(cname.split("_")[2:])
cname = re.sub(r"^build_include_", "", cname)
cname = re.sub(r"_inc_c$", "", cname)
with open(outfile, "w") as f:
f.write(f"unsigned char {cname}[] = {{")
with open(infile, "rb") as i:
for char in i.read():
f.write(f"{char},")
f.write(f"}};\n")