Login
7 branches 0 tags
Ben (Win10) GH CI Valgrind now tracks the origin 706e8b9 3 years ago 823 Commits
nujel / tools / update-stdlib.nuj
#!/usr/bin/env nujel

[defn create-c-asset [filename output-file symbol-name]
      [typecheck/only filename :string]
      [typecheck/only output-file :string]
      [typecheck/only symbol-name :string]
      [def raw [slurp filename]]
      [def out [make-output-port [file/open-output* output-file :replace]]]
      [out 'block-write "/* This file is auto-generated, manual changes will be overwritten! */\n"]
      [out 'block-write [fmt "unsigned char {symbol-name}[] = "]]
      [out 'block-write "{"]
      [dotimes [i [buffer/length raw]]
               [when [zero? [rem i 32]]
                     [out 'block-write "\n"]]
               [def c [buffer/ref raw i]]
               [out 'block-write [fmt "0x{c:02X}, "]]]
      [out 'block-write "0\n};\n"]
      [out 'close!]]