mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-10 03:47:29 -03:00
2a581144f2
Tested the performance with: > time cmake -DJSON_SOURCE_PATH=src/secp256k1/src/wycheproof/ecdsa_secp256k1_sha256_bitcoin_test.json -DHEADER_PATH=build/after/ecdsa_secp256k1_sha256_bitcoin_test.json -P cmake/script/GenerateHeaderFromJson.cmake Before: > 3.57s user 6.01s system 94% cpu 10.136 total After: > 0.17s user 0.01s system 98% cpu 0.187 total
22 lines
814 B
CMake
22 lines
814 B
CMake
# Copyright (c) 2023-present The Bitcoin Core developers
|
|
# Distributed under the MIT software license, see the accompanying
|
|
# file COPYING or https://opensource.org/license/mit/.
|
|
|
|
cmake_path(GET JSON_SOURCE_PATH STEM json_source_basename)
|
|
|
|
file(READ ${JSON_SOURCE_PATH} hex_content HEX)
|
|
string(REGEX REPLACE "................" "\\0\n" formatted_bytes "${hex_content}")
|
|
string(REGEX REPLACE "[^\n][^\n]" "0x\\0, " formatted_bytes "${formatted_bytes}")
|
|
|
|
set(header_content
|
|
"#include <string_view>
|
|
|
|
namespace json_tests {
|
|
inline constexpr char detail_${json_source_basename}_bytes[] {
|
|
${formatted_bytes}
|
|
};
|
|
|
|
inline constexpr std::string_view ${json_source_basename}{std::begin(detail_${json_source_basename}_bytes), std::end(detail_${json_source_basename}_bytes)};
|
|
}
|
|
")
|
|
file(WRITE ${HEADER_PATH} "${header_content}")
|