Skip to content

Instantly share code, notes, and snippets.

@michaelneu
Created January 21, 2020 09:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michaelneu/e6a75b1308bbcef6cdf6b62a16817b40 to your computer and use it in GitHub Desktop.
Save michaelneu/e6a75b1308bbcef6cdf6b62a16817b40 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
import sys
if __name__ == "__main__":
filename = sys.argv[1] if len(sys.argv) == 2 else "main.wasm"
print("[*] Reading", filename)
with open(filename, "rb") as content_fh:
content = content_fh.read()
print("[*] Generating header from %d wasm bytes" % len(content))
with open("../include/test.hpp", "w") as out_fh:
wasm_bytes = ", ".join([hex(byte) for byte in content])
out_fh.write("char wasm_test_bytes[] = { %s };" % wasm_bytes)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment