Skip to content

Commit

Permalink
CMakeLists tests: add raw files generation.
Browse files Browse the repository at this point in the history
  • Loading branch information
furszy committed Jun 11, 2021
1 parent 0248267 commit 715bcad
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 3 deletions.
File renamed without changes.
35 changes: 32 additions & 3 deletions src/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function(GenerateHeaders)
foreach(file IN LISTS ARGN)
get_filename_component(VARNAME ${file} NAME_WE)
set(outFile ${file}.h)
set(runCmd ${CMAKE_SOURCE_DIR}/contrib/devtools/gen-json-headers.sh)
set(runCmd ${CMAKE_SOURCE_DIR}/contrib/devtools/hexdump_util.sh)
add_custom_command(
OUTPUT ${outFile}
COMMAND ${CMAKE_COMMAND} -E echo "namespace json_tests{" > ${outFile}
Expand All @@ -38,7 +38,6 @@ function(GenerateHeaders)
DEPENDS ${file}
COMMENT "Generating ${file}.h"
VERBATIM

)
list(APPEND OutputFileList ${outFile})
endforeach()
Expand All @@ -52,6 +51,36 @@ endfunction()

GenerateHeaders(${JSON_TEST_FILES})

set(RAW_TEST_FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/asmap.raw)

# Generate raw files
function(GenerateRaws)
set(fileList "")
foreach(file IN LISTS ARGN)
get_filename_component(filename ${file} NAME_WE)
set(outFile ${file}.h)
set(runCmd ${CMAKE_SOURCE_DIR}/contrib/devtools/hexdump_util.sh)
add_custom_command(
OUTPUT ${outFile}
COMMAND ${CMAKE_COMMAND} -E echo "static unsigned const char ${filename}_raw[] = {" > ${outFile}
COMMAND ${runCmd} ${file} ${outFile}
COMMAND ${CMAKE_COMMAND} -E echo "};" >> ${outFile}
DEPENDS ${file}
COMMENT "Generating raw ${file}.h"
VERBATIM
)
list(APPEND fileList ${outFile})
endforeach()
install(FILES ${fileList} DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/data)
add_custom_target(
genRaws ALL
DEPENDS ${fileList}
COMMENT "Processing raw files..."
)
endfunction()

GenerateRaws(${RAW_TEST_FILES})

set(BITCOIN_TEST_SUITE
${CMAKE_CURRENT_SOURCE_DIR}/test_pivx.h
${CMAKE_CURRENT_SOURCE_DIR}/test_pivx.cpp
Expand Down Expand Up @@ -147,7 +176,7 @@ set(BITCOIN_TESTS

set(test_test_pivx_SOURCES ${BITCOIN_TEST_SUITE} ${BITCOIN_TESTS} ${JSON_TEST_FILES})
add_executable(test_pivx ${test_test_pivx_SOURCES} ${BitcoinHeaders})
add_dependencies(test_pivx genHeaders libunivalue libsecp256k1 libzcashrust leveldb crc32c)
add_dependencies(test_pivx genHeaders genRaws libunivalue libsecp256k1 libzcashrust leveldb crc32c)
target_include_directories(test_pivx PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_SOURCE_DIR}/src/leveldb
${CMAKE_SOURCE_DIR}/src/leveldb/include
Expand Down

0 comments on commit 715bcad

Please sign in to comment.