From aed38ea58cbde068fe12b5299b246b4e3649a09c Mon Sep 17 00:00:00 2001 From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Date: Sat, 13 Jul 2024 12:37:17 +0100 Subject: [PATCH] cmake: Build `bitcoinkernel` library Co-authored-by: TheCharlatan --- CMakeLists.txt | 4 ++ src/CMakeLists.txt | 5 ++ src/kernel/CMakeLists.txt | 99 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 108 insertions(+) create mode 100644 src/kernel/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 39da68510e3..ca33587a139 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -74,6 +74,8 @@ option(BUILD_TESTS "Build test_bitcoin executable." ON) option(BUILD_TX "Build bitcoin-tx executable." ${BUILD_TESTS}) option(BUILD_UTIL "Build bitcoin-util executable." ${BUILD_TESTS}) +option(BUILD_KERNEL_LIB "Build experimental bitcoinkernel library." OFF) + option(ENABLE_WALLET "Enable wallet." ON) option(WITH_SQLITE "Enable SQLite wallet support." ${ENABLE_WALLET}) if(WITH_SQLITE) @@ -205,6 +207,7 @@ if(BUILD_FOR_FUZZING) set(BUILD_CLI OFF) set(BUILD_TX OFF) set(BUILD_UTIL OFF) + set(BUILD_KERNEL_LIB OFF) set(BUILD_WALLET_TOOL OFF) set(BUILD_GUI OFF) set(ENABLE_EXTERNAL_SIGNER OFF) @@ -495,6 +498,7 @@ message(" bitcoin-cli ......................... ${BUILD_CLI}") message(" bitcoin-tx .......................... ${BUILD_TX}") message(" bitcoin-util ........................ ${BUILD_UTIL}") message(" bitcoin-wallet ...................... ${BUILD_WALLET_TOOL}") +message(" libbitcoinkernel (experimental) ..... ${BUILD_KERNEL_LIB}") message("Optional features:") message(" wallet support ...................... ${ENABLE_WALLET}") if(ENABLE_WALLET) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 89486eb72a3..26a95ec3e82 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -349,6 +349,11 @@ if(BUILD_GUI) endif() +if(BUILD_KERNEL_LIB) + add_subdirectory(kernel) +endif() + + add_subdirectory(test/util) if(BUILD_BENCH) add_subdirectory(bench) diff --git a/src/kernel/CMakeLists.txt b/src/kernel/CMakeLists.txt new file mode 100644 index 00000000000..722fd31aebf --- /dev/null +++ b/src/kernel/CMakeLists.txt @@ -0,0 +1,99 @@ +# Copyright (c) 2024-present The Bitcoin Core developers +# Distributed under the MIT software license, see the accompanying +# file COPYING or https://opensource.org/license/mit/. + +# TODO: libbitcoinkernel is a work in progress consensus engine +# library, as more and more modules are decoupled from the +# consensus engine, this list will shrink to only those +# which are absolutely necessary. +add_library(bitcoinkernel + bitcoinkernel.cpp + chain.cpp + checks.cpp + chainparams.cpp + coinstats.cpp + context.cpp + cs_main.cpp + disconnected_transactions.cpp + mempool_removal_reason.cpp + ../arith_uint256.cpp + ../chain.cpp + ../coins.cpp + ../compressor.cpp + ../consensus/merkle.cpp + ../consensus/tx_check.cpp + ../consensus/tx_verify.cpp + ../core_read.cpp + ../dbwrapper.cpp + ../deploymentinfo.cpp + ../deploymentstatus.cpp + ../flatfile.cpp + ../hash.cpp + ../logging.cpp + ../node/blockstorage.cpp + ../node/chainstate.cpp + ../node/utxo_snapshot.cpp + ../policy/feerate.cpp + ../policy/packages.cpp + ../policy/policy.cpp + ../policy/rbf.cpp + ../policy/settings.cpp + ../policy/truc_policy.cpp + ../pow.cpp + ../primitives/block.cpp + ../primitives/transaction.cpp + ../pubkey.cpp + ../random.cpp + ../randomenv.cpp + ../script/interpreter.cpp + ../script/script.cpp + ../script/script_error.cpp + ../script/sigcache.cpp + ../script/solver.cpp + ../signet.cpp + ../streams.cpp + ../support/lockedpool.cpp + ../sync.cpp + ../txdb.cpp + ../txmempool.cpp + ../uint256.cpp + ../util/chaintype.cpp + ../util/check.cpp + ../util/feefrac.cpp + ../util/fs.cpp + ../util/fs_helpers.cpp + ../util/hasher.cpp + ../util/moneystr.cpp + ../util/rbf.cpp + ../util/serfloat.cpp + ../util/signalinterrupt.cpp + ../util/strencodings.cpp + ../util/string.cpp + ../util/syserror.cpp + ../util/threadnames.cpp + ../util/time.cpp + ../util/tokenpipe.cpp + ../validation.cpp + ../validationinterface.cpp + ../versionbits.cpp +) +target_link_libraries(bitcoinkernel + PRIVATE + core_interface + bitcoin_clientversion + bitcoin_crypto + leveldb + secp256k1 + PUBLIC + Boost::headers +) + +# libbitcoinkernel requires default symbol visibility, explicitly +# specify that here so that things still work even when user +# configures with -DREDUCE_EXPORTS=ON +# +# Note this is a quick hack that will be removed as we +# incrementally define what to export from the library. +set_target_properties(bitcoinkernel PROPERTIES + CXX_VISIBILITY_PRESET default +)