Make amalg build cleaner.

Don't pull in a global header <janet/janet.h> unless we need to.
This commit is contained in:
Calvin Rose
2019-02-16 23:33:24 -05:00
parent c715912ea3
commit 6d5ff43de7
3 changed files with 28 additions and 27 deletions
+7 -5
View File
@@ -25,14 +25,16 @@
# Create C source file that contains images a uint8_t buffer. This
# can be compiled and linked statically into the main janet library
# and example client.
(def chunks (seq [b :in image] (string b)))
(def chunks (string/bytes image))
(def image-file (file/open "build/core_image.c" :w))
(file/write image-file
"#ifndef JANET_AMALG\n"
"#include <janet/janet.h>\n"
"static const unsigned char janet_core_image_bytes[] = {")
(loop [line :in (partition 16 chunks)]
(def str (string ;(interpose ", " line)))
(file/write image-file str ",\n"))
"#endif\n"
"static const unsigned char janet_core_image_bytes[] = {\n")
(loop [line :in (partition 10 chunks)]
(def str (string ;(interpose ", " (map (partial string/format "0x%.2X") line))))
(file/write image-file " " str ",\n"))
(file/write image-file
"0};\n\n"
"const unsigned char *janet_core_image = janet_core_image_bytes;\n"