#!/usr/bin/env python3 #This file is part of the IVD project and is licensed under LGPL-3.0-only from sys import argv blah, inputBinaryFile, includePath, variableName, outputName = argv output = [] with open(inputBinaryFile, "rb") as f: byte = f.read(1) while byte: output.append("0x" + byte.hex()) byte = f.read(1) with open(outputName, "w") as f: f.write("//This file was generated at build time.\n") f.write("#include \"%s\"\n" % includePath) f.write("const unsigned char %s[] = {\n" % variableName) length = len(output) i = 1; for char in output: f.write(char) if i != length: f.write(",") if i and not i % 12: f.write("\n") elif i != length: f.write(" ") i += 1 f.write("};\n") f.write("const int %sSize = %d;\n" % (variableName, len(output)))