diff options
author | Jan200101 <sentrycraft123@gmail.com> | 2021-06-06 17:10:10 +0200 |
---|---|---|
committer | Jan200101 <sentrycraft123@gmail.com> | 2021-06-06 17:10:10 +0200 |
commit | 537994756d80178bdaf25e96968f34d2e144797f (patch) | |
tree | a093dfc43a8487c5866808e74e7250a6818cf6e0 /cmake | |
parent | df1df2929646abd77955b80e3ded3574ac005179 (diff) | |
download | polecat-537994756d80178bdaf25e96968f34d2e144797f.tar.gz polecat-537994756d80178bdaf25e96968f34d2e144797f.zip |
fix win env, add proper mocking code to test implementation
Diffstat (limited to 'cmake')
-rw-r--r-- | cmake/FileEmbed.cmake | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/cmake/FileEmbed.cmake b/cmake/FileEmbed.cmake new file mode 100644 index 0000000..d8fc882 --- /dev/null +++ b/cmake/FileEmbed.cmake @@ -0,0 +1,12 @@ +get_filename_component(bin_name ${bin_in} NAME) +string(REGEX REPLACE "\\.| |-" "_" bin_name ${bin_name}) + +set(c_out ${bin_name}.c) +set(h_out ${bin_name}.h) + +file(READ ${bin_in} filedata HEX) + +string(REGEX REPLACE "([0-9a-f][0-9a-f])" "0x\\1," filedata ${filedata}) + +file(WRITE ${c_out} "#include <stdlib.h>\nconst unsigned char ${bin_name}[] = {${filedata}};\nconst size_t ${bin_name}_size = sizeof(${bin_name});\n") +file(WRITE ${h_out} "extern const unsigned char ${bin_name}[];\nextern const size_t ${bin_name}_size;\n") |