aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorselsta <selsta@sent.at>2021-04-28 16:13:19 +0200
committerselsta <selsta@sent.at>2021-08-01 15:47:05 +0200
commit8716d2ad9dbb27d28d806ab548ea161dd36a7a58 (patch)
tree37863f9ef8c50321808f856c748e9ada742a71e2 /src
parentMerge pull request #7815 (diff)
downloadmonero-8716d2ad9dbb27d28d806ab548ea161dd36a7a58.tar.xz
cmake: fix non portable code
Diffstat (limited to 'src')
-rw-r--r--src/blocks/CMakeLists.txt30
1 files changed, 21 insertions, 9 deletions
diff --git a/src/blocks/CMakeLists.txt b/src/blocks/CMakeLists.txt
index 051c60886..071ccd506 100644
--- a/src/blocks/CMakeLists.txt
+++ b/src/blocks/CMakeLists.txt
@@ -28,20 +28,32 @@
set(GENERATED_SOURCES "")
+set(GENERATOR "${CMAKE_CURRENT_BINARY_DIR}/blocks_generator.cmake")
+file(GENERATE OUTPUT ${GENERATOR} CONTENT [=[
+file(READ "${INPUT_DAT_FILE}" DATA HEX)
+string(REGEX REPLACE "[0-9a-fA-F][0-9a-fA-F]" "0x\\0," DATA "${DATA}")
+file(WRITE "${OUTPUT_C_SOURCE}" "
+#include <stddef.h>
+const unsigned char ${BLOB_NAME}[]={
+ ${DATA}
+};
+const size_t ${BLOB_NAME}_len = sizeof(${BLOB_NAME});
+"
+)
+]=])
foreach(BLOB_NAME checkpoints testnet_blocks stagenet_blocks)
set(OUTPUT_C_SOURCE "generated_${BLOB_NAME}.c")
list(APPEND GENERATED_SOURCES ${OUTPUT_C_SOURCE})
set(INPUT_DAT_FILE "${BLOB_NAME}.dat")
add_custom_command(
- OUTPUT ${OUTPUT_C_SOURCE}
- MAIN_DEPENDENCY ${INPUT_DAT_FILE}
- COMMAND
- cd ${CMAKE_CURRENT_BINARY_DIR} &&
- echo "'#include\t<stddef.h>'" > ${OUTPUT_C_SOURCE} &&
- echo "'const\tunsigned\tchar\t${BLOB_NAME}[]={'" >> ${OUTPUT_C_SOURCE} &&
- od -v -An -tx1 ${CMAKE_CURRENT_SOURCE_DIR}/${INPUT_DAT_FILE} | sed -e "'s/[0-9a-fA-F]\\{1,\\}/0x&,/g'" -e "'$$s/.$$//'" >> ${OUTPUT_C_SOURCE} &&
- echo "'};'" >> ${OUTPUT_C_SOURCE} &&
- echo "'const\tsize_t\t${BLOB_NAME}_len\t=\tsizeof(${BLOB_NAME});'" >> ${OUTPUT_C_SOURCE}
+ OUTPUT ${OUTPUT_C_SOURCE}
+ MAIN_DEPENDENCY ${INPUT_DAT_FILE}
+ DEPENDS ${GENERATOR}
+ COMMAND ${CMAKE_COMMAND}
+ "-DINPUT_DAT_FILE=${CMAKE_CURRENT_SOURCE_DIR}/${INPUT_DAT_FILE}"
+ "-DBLOB_NAME=${BLOB_NAME}"
+ "-DOUTPUT_C_SOURCE=${CMAKE_CURRENT_BINARY_DIR}/${OUTPUT_C_SOURCE}"
+ "-P${GENERATOR}"
)
endforeach()