aboutsummaryrefslogtreecommitdiff
path: root/cmake/FileEmbed.cmake
blob: 8547f6a121d9444220a584ff18fb24710950385e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
get_filename_component(bin_name ${bin_in} NAME)
string(REGEX REPLACE "\\.| |-" "_" bin_name ${bin_name})

set(c_out ${bin_name}.c)

file(READ ${bin_in} filedata HEX)

message(${c_out})

string(REGEX REPLACE  "([0-9a-f][0-9a-f])" "0x\\1," filedata ${filedata})

file(WRITE ${c_out} "#include <stddef.h>\n#include <stdint.h>\nconst uint8_t ${bin_name}[] = {${filedata}};\nconst size_t ${bin_name}_size = sizeof(${bin_name});\n")