aboutsummaryrefslogtreecommitdiffstats
path: root/cmake/bin2h.script.cmake
diff options
context:
space:
mode:
Diffstat (limited to 'cmake/bin2h.script.cmake')
-rw-r--r--cmake/bin2h.script.cmake12
1 files changed, 12 insertions, 0 deletions
diff --git a/cmake/bin2h.script.cmake b/cmake/bin2h.script.cmake
new file mode 100644
index 00000000..7e74a7a1
--- /dev/null
+++ b/cmake/bin2h.script.cmake
@@ -0,0 +1,12 @@
+# Read the input file into 'indata', converting each byte to a pair of hex
+# characters
+file(READ "${INPUT_FILE}" indata HEX)
+
+# For each pair of characters, indent them and prepend the 0x prefix, and
+# append a comma separateor.
+# TODO: Prettify this. Should group a number of bytes per line instead of one
+# per line.
+string(REGEX REPLACE "(..)" " 0x\\1,\n" output "${indata}")
+
+# Write the list of hex chars to the output file
+file(WRITE "${OUTPUT_FILE}" "${output}")