From cc2d1370dbd42e7ab90366d87e12d9df314edcdb Mon Sep 17 00:00:00 2001 From: Pelle Nilsson Date: Mon, 29 Jul 2024 11:57:12 +0200 Subject: [PATCH] Python3 fixes --- build.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/build.py b/build.py index fcc3011..cfdaf3b 100755 --- a/build.py +++ b/build.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python3 import os, sys, shutil, re, textwrap COMPILER = "i586-pc-msdosdjgpp-gcc" @@ -28,7 +28,7 @@ def make_c_include(name, data): name = re.sub("[^a-z0-9]", "_", name.lower()) res = "static const char " + name + "[] = {" for c in data: - res += str(ord(c)) + ", " + res += str(c) + ", " res = res.rstrip(", ") + "};" return name, textwrap.fill(res, width=79) @@ -46,8 +46,9 @@ def main(): for filename in embedded_files: name = os.path.basename(filename) - name, text = make_c_include(name, open(filename).read()) - open("%s/%s.h" % (TEMPSRC_DIR, name), "wb").write(text) + print(f"filename: {filename}") + name, text = make_c_include(name, open(filename, "rb").read()) + open("%s/%s.h" % (TEMPSRC_DIR, name), "wb").write(text.encode()) cfiles = filter(lambda x: x.endswith((".c", ".C")), listdir(SRC_DIR))