File tree Expand file tree Collapse file tree 12 files changed +24
-54
lines changed Expand file tree Collapse file tree 12 files changed +24
-54
lines changed Original file line number Diff line number Diff line change @@ -11,10 +11,10 @@ function(generate_header_from_json json_source_relpath)
11
11
)
12
12
endfunction ()
13
13
14
- function (generate_header_from_raw raw_source_relpath )
14
+ function (generate_header_from_raw raw_source_relpath raw_namespace )
15
15
add_custom_command (
16
16
OUTPUT ${CMAKE_CURRENT_BINARY_DIR} /${raw_source_relpath}.h
17
- COMMAND ${CMAKE_COMMAND} -DRAW_SOURCE_PATH=${CMAKE_CURRENT_SOURCE_DIR}/${raw_source_relpath} -DHEADER_PATH=${CMAKE_CURRENT_BINARY_DIR}/${raw_source_relpath}.h -P ${PROJECT_SOURCE_DIR} /cmake/script/GenerateHeaderFromRaw.cmake
17
+ COMMAND ${CMAKE_COMMAND} -DRAW_SOURCE_PATH=${CMAKE_CURRENT_SOURCE_DIR}/${raw_source_relpath} -DHEADER_PATH=${CMAKE_CURRENT_BINARY_DIR}/${raw_source_relpath}.h -DRAW_NAMESPACE=${raw_namespace} - P ${PROJECT_SOURCE_DIR} /cmake/script/GenerateHeaderFromRaw.cmake
18
18
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR} /${raw_source_relpath} ${PROJECT_SOURCE_DIR} /cmake/script/GenerateHeaderFromRaw.cmake
19
19
VERBATIM
20
20
)
Original file line number Diff line number Diff line change 5
5
file (READ ${RAW_SOURCE_PATH} hex_content HEX )
6
6
string (REGEX MATCHALL "([A-Za-z0-9][A-Za-z0-9])" bytes "${hex_content} " )
7
7
8
+ file (WRITE ${HEADER_PATH} "#include <cstddef>\n " )
9
+ file (APPEND ${HEADER_PATH} "#include <span>\n " )
10
+ file (APPEND ${HEADER_PATH} "namespace ${RAW_NAMESPACE} {\n " )
8
11
get_filename_component (raw_source_basename ${RAW_SOURCE_PATH} NAME_WE )
9
- file (WRITE ${HEADER_PATH} "static unsigned const char ${raw_source_basename} _raw[] = {\n " )
12
+ file (APPEND ${HEADER_PATH} "inline constexpr std::byte detail_ ${raw_source_basename} _raw[]{\n " )
10
13
11
14
set (i 0 )
12
15
foreach (byte ${bytes} )
13
16
math (EXPR i "${i} + 1" )
14
17
math (EXPR remainder "${i} % 8" )
15
18
if (remainder EQUAL 0 )
16
- file (APPEND ${HEADER_PATH} "0x${byte} ,\n " )
19
+ file (APPEND ${HEADER_PATH} "std::byte{ 0x${byte} },\n " )
17
20
else ()
18
- file (APPEND ${HEADER_PATH} "0x${byte} , " )
21
+ file (APPEND ${HEADER_PATH} "std::byte{ 0x${byte} }, " )
19
22
endif ()
20
23
endforeach ()
21
24
22
- file (APPEND ${HEADER_PATH} "\n };" )
25
+ file (APPEND ${HEADER_PATH} "\n };\n " )
26
+ file (APPEND ${HEADER_PATH} "inline constexpr std::span ${raw_source_basename} {detail_${raw_source_basename} _raw};\n " )
27
+ file (APPEND ${HEADER_PATH} "}" )
Original file line number Diff line number Diff line change 3
3
# file COPYING or https://opensource.org/license/mit/.
4
4
5
5
include (GenerateHeaders )
6
- generate_header_from_raw (data/block413567.raw )
6
+ generate_header_from_raw (data/block413567.raw benchmark::data )
7
7
8
8
add_executable (bench_bitcoin
9
9
bench_bitcoin.cpp
10
10
bench.cpp
11
- data.cpp
12
11
nanobench.cpp
13
12
${CMAKE_CURRENT_BINARY_DIR} /data/block413567.raw.h
14
13
# Benchmarks:
Original file line number Diff line number Diff line change 3
3
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
4
5
5
#include < bench/bench.h>
6
- #include < bench/data.h>
6
+ #include < bench/data/block413567.raw .h>
7
7
#include < chainparams.h>
8
8
#include < common/args.h>
9
9
#include < consensus/validation.h>
Load Diff This file was deleted.
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 3
3
// file COPYING or https://www.opensource.org/licenses/mit-license.php.
4
4
5
5
#include < bench/bench.h>
6
- #include < bench/data.h>
6
+ #include < bench/data/block413567.raw .h>
7
7
#include < chainparams.h>
8
8
#include < flatfile.h>
9
9
#include < node/blockstorage.h>
Original file line number Diff line number Diff line change 3
3
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
4
5
5
#include < bench/bench.h>
6
- #include < bench/data.h>
6
+ #include < bench/data/block413567.raw .h>
7
7
#include < flatfile.h>
8
8
#include < node/blockstorage.h>
9
9
#include < primitives/block.h>
Original file line number Diff line number Diff line change 3
3
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
4
5
5
#include < bench/bench.h>
6
- #include < bench/data.h>
6
+ #include < bench/data/block413567.raw .h>
7
7
#include < chain.h>
8
8
#include < core_io.h>
9
9
#include < primitives/block.h>
Original file line number Diff line number Diff line change 3
3
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
4
5
5
#include < bench/bench.h>
6
- #include < bench/data.h>
6
+ #include < bench/data/block413567.raw .h>
7
7
#include < span.h>
8
8
#include < util/strencodings.h>
9
9
You can’t perform that action at this time.
0 commit comments