mirror of
https://github.com/davidgiven/fluxengine.git
synced 2025-10-24 11:11:02 -07:00
Don't use xxd to objectify files.
This commit is contained in:
19
build/_objectify.py
Normal file
19
build/_objectify.py
Normal file
@@ -0,0 +1,19 @@
|
||||
import sys
|
||||
from functools import partial
|
||||
|
||||
if len(sys.argv) != 3:
|
||||
sys.exit("Usage: %s <file> <symbol>" % sys.argv[0])
|
||||
filename = sys.argv[1]
|
||||
symbol = sys.argv[2]
|
||||
|
||||
print("const uint8_t " + symbol + "[] = {")
|
||||
n = 0
|
||||
with open(filename, "rb") as in_file:
|
||||
for c in iter(partial(in_file.read, 1), b""):
|
||||
print("0x%02X," % ord(c), end="")
|
||||
n += 1
|
||||
if n % 16 == 0:
|
||||
print()
|
||||
print("};")
|
||||
|
||||
print("const size_t " + symbol + "_len = sizeof(" + symbol + ");")
|
||||
@@ -6,9 +6,9 @@ from os.path import basename
|
||||
def objectify(self, name, src: Target, symbol):
|
||||
normalrule(
|
||||
replaces=self,
|
||||
ins=[src],
|
||||
ins=["build/_objectify.py", src],
|
||||
outs=[basename(filenameof(src)) + ".h"],
|
||||
commands=["xxd -i -n " + symbol + " {ins} > {outs}"],
|
||||
commands=["$(PYTHON) {ins[0]} {ins[1]} " + symbol + " > {outs}"],
|
||||
label="OBJECTIFY",
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user