Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: Add CMake-based build system (6 of N) #15

Merged
merged 14 commits into from
Jul 7, 2023
Merged
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ project("Bitcoin Core"
LANGUAGES CXX ASM
)

set(PACKAGE_NAME ${PROJECT_NAME})
set(CLIENT_VERSION_IS_RELEASE "false")
set(COPYRIGHT_YEAR "2023")
set(COPYRIGHT_HOLDERS "The %s developers")
Expand Down Expand Up @@ -152,6 +153,7 @@ else()
endif()

add_subdirectory(src)
add_subdirectory(test)

message("\n")
message("Configure summary")
Expand Down
52 changes: 52 additions & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Copyright (c) 2023 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.

function(create_test_config)
set(abs_top_srcdir ${PROJECT_SOURCE_DIR})
set(abs_top_builddir ${PROJECT_BINARY_DIR})
set(EXEEXT ${CMAKE_EXECUTABLE_SUFFIX})

macro(set_configure_variable var conf_var)
if(${var})
set(${conf_var}_TRUE "")
else()
set(${conf_var}_TRUE "#")
endif()
endmacro()

set_configure_variable(ENABLE_WALLET ENABLE_WALLET)
set_configure_variable(WITH_SQLITE USE_SQLITE)
set_configure_variable(WITH_BDB USE_BDB)
set_configure_variable(BUILD_CLI BUILD_BITCOIN_CLI)
set_configure_variable(BUILD_UTIL BUILD_BITCOIN_UTIL)
set_configure_variable(BUILD_WALLET_TOOL BUILD_BITCOIN_WALLET)
set_configure_variable(BUILD_DAEMON BUILD_BITCOIND_TRUE)
set_configure_variable(WITH_ZMQ ENABLE_ZMQ)
set_configure_variable(ENABLE_EXTERNAL_SIGNER ENABLE_EXTERNAL_SIGNER)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Afaict these last three are still missing, right?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ENABLE_EXTERNAL_SIGNER an USE_SYSCALL_SANDBOX variables are not introduced in this PR. As for ENABLE_TRACING, see

if(WITH_USDT)
check_cxx_source_compiles("
#include <sys/sdt.h>
int main()
{
DTRACE_PROBE(\"context\", \"event\");
}
" HAVE_USDT_H
)
if(HAVE_USDT_H)
set(ENABLE_TRACING TRUE)
set(WITH_USDT ON)
elseif(WITH_USDT STREQUAL "AUTO")
set(WITH_USDT OFF)
else()
message(FATAL_ERROR "sys/sdt.h requested, but not found.")
endif()
endif()

Anyway, the processing of the test/config.ini.in file expects all three variables set:

  • ENABLE_EXTERNAL_SIGNER_TRUE
  • ENABLE_SYSCALL_SANDBOX_TRUE
  • ENABLE_USDT_TRACEPOINTS_TRUE

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, all good then :)

set_configure_variable(USE_SYSCALL_SANDBOX ENABLE_SYSCALL_SANDBOX)
set_configure_variable(ENABLE_TRACING ENABLE_USDT_TRACEPOINTS)

configure_file(config.ini.in config.ini @ONLY)
endfunction()

create_test_config()

file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/functional)
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/fuzz)
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/util)

function(create_test_script script)
if(MSVC)
file(CREATE_LINK ${CMAKE_CURRENT_SOURCE_DIR}/${script} ${CMAKE_CURRENT_BINARY_DIR}/${script} COPY_ON_ERROR)
elseif(CMAKE_VERSION VERSION_GREATER_EQUAL 3.14)
file(CREATE_LINK ${CMAKE_CURRENT_SOURCE_DIR}/${script} ${CMAKE_CURRENT_BINARY_DIR}/${script} COPY_ON_ERROR SYMBOLIC)
else()
file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/${script})
execute_process(COMMAND ln -s ${CMAKE_CURRENT_SOURCE_DIR}/${script} ${CMAKE_CURRENT_BINARY_DIR}/${script})
endif()
endfunction()

foreach(script functional/test_runner.py fuzz/test_runner.py util/rpcauth-test.py util/test_runner.py)
create_test_script(${script})
endforeach()