From 866bbb98fd365962840ee99df0d9f7ad557cc025 Mon Sep 17 00:00:00 2001 From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Date: Wed, 5 Nov 2025 21:39:58 +0000 Subject: [PATCH] cmake, test: Improve locality of `bitcoin_ipc_test` library description --- src/CMakeLists.txt | 16 ---------------- src/ipc/CMakeLists.txt | 25 ++++++++++++++++++++++++- src/ipc/test/CMakeLists.txt | 7 ------- src/{ => ipc}/test/ipc_test.capnp | 6 +++--- src/{ => ipc}/test/ipc_test.cpp | 6 +++--- src/{ => ipc}/test/ipc_test.h | 6 +++--- src/{ => ipc}/test/ipc_test_types.h | 8 ++++---- src/ipc/test/ipc_tests.cpp | 2 +- 8 files changed, 38 insertions(+), 38 deletions(-) rename src/{ => ipc}/test/ipc_test.capnp (83%) rename src/{ => ipc}/test/ipc_test.cpp (98%) rename src/{ => ipc}/test/ipc_test.h (88%) rename src/{ => ipc}/test/ipc_test_types.h (61%) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index bcadd675346..0810f6360ea 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -325,22 +325,6 @@ if(ENABLE_IPC AND BUILD_DAEMON) install_binary_component(bitcoin-node INTERNAL) endif() -if(ENABLE_IPC AND BUILD_TESTS) - # bitcoin_ipc_test library target is defined here in src/CMakeLists.txt - # instead of src/test/CMakeLists.txt so capnp files in src/test/ are able to - # reference capnp files in src/ipc/capnp/ by relative path. The Cap'n Proto - # compiler only allows importing by relative path when the importing and - # imported files are underneath the same compilation source prefix, so the - # source prefix must be src/, not src/test/ - add_library(bitcoin_ipc_test STATIC EXCLUDE_FROM_ALL - test/ipc_test.cpp - ) - target_capnp_sources(bitcoin_ipc_test ${PROJECT_SOURCE_DIR} - test/ipc_test.capnp - ) - add_dependencies(bitcoin_ipc_test bitcoin_ipc_headers) -endif() - add_library(bitcoin_cli STATIC EXCLUDE_FROM_ALL compat/stdin.cpp diff --git a/src/ipc/CMakeLists.txt b/src/ipc/CMakeLists.txt index 8f0437be35a..300da122505 100644 --- a/src/ipc/CMakeLists.txt +++ b/src/ipc/CMakeLists.txt @@ -9,7 +9,7 @@ add_library(bitcoin_ipc STATIC EXCLUDE_FROM_ALL process.cpp ) -target_capnp_sources(bitcoin_ipc ${PROJECT_SOURCE_DIR} +target_capnp_sources(bitcoin_ipc ${CMAKE_CURRENT_SOURCE_DIR} capnp/common.capnp capnp/echo.capnp capnp/init.capnp @@ -22,4 +22,27 @@ target_link_libraries(bitcoin_ipc univalue ) +if(BUILD_TESTS) + # bitcoin_ipc_test library target is defined here in src/ipc/CMakeLists.txt + # instead of src/ipc/test/CMakeLists.txt so capnp files in src/ipc/test/ are able to + # reference capnp files in src/ipc/capnp/ by relative path. The Cap'n Proto + # compiler only allows importing by relative path when the importing and + # imported files are underneath the same compilation source prefix, so the + # source prefix must be src/ipc, not src/ipc/test/ + add_library(bitcoin_ipc_test STATIC EXCLUDE_FROM_ALL + test/ipc_test.cpp + ) + target_capnp_sources(bitcoin_ipc_test ${CMAKE_CURRENT_SOURCE_DIR} + test/ipc_test.capnp + ) + add_dependencies(bitcoin_ipc_test bitcoin_ipc_headers) + + target_link_libraries(bitcoin_ipc_test + PRIVATE + core_interface + univalue + Boost::headers + ) +endif() + configure_file(.clang-tidy.in .clang-tidy USE_SOURCE_PERMISSIONS COPYONLY) diff --git a/src/ipc/test/CMakeLists.txt b/src/ipc/test/CMakeLists.txt index a9bb02f59e0..e71bc2bc6a1 100644 --- a/src/ipc/test/CMakeLists.txt +++ b/src/ipc/test/CMakeLists.txt @@ -2,13 +2,6 @@ # Distributed under the MIT software license, see the accompanying # file COPYING or https://opensource.org/license/mit/. -target_link_libraries(bitcoin_ipc_test - PRIVATE - core_interface - univalue - Boost::headers -) - # Do not use generator expressions in test sources because the # SOURCES property is processed to gather test suite macros. target_sources(test_bitcoin diff --git a/src/test/ipc_test.capnp b/src/ipc/test/ipc_test.capnp similarity index 83% rename from src/test/ipc_test.capnp rename to src/ipc/test/ipc_test.capnp index e33f711bf3c..5e8dfd5dc38 100644 --- a/src/test/ipc_test.capnp +++ b/src/ipc/test/ipc_test.capnp @@ -8,10 +8,10 @@ using Cxx = import "/capnp/c++.capnp"; $Cxx.namespace("gen"); using Proxy = import "/mp/proxy.capnp"; -$Proxy.include("test/ipc_test.h"); -$Proxy.includeTypes("test/ipc_test_types.h"); +$Proxy.include("ipc/test/ipc_test.h"); +$Proxy.includeTypes("ipc/test/ipc_test_types.h"); -using Mining = import "../ipc/capnp/mining.capnp"; +using Mining = import "../capnp/mining.capnp"; interface FooInterface $Proxy.wrap("FooImplementation") { add @0 (a :Int32, b :Int32) -> (result :Int32); diff --git a/src/test/ipc_test.cpp b/src/ipc/test/ipc_test.cpp similarity index 98% rename from src/test/ipc_test.cpp rename to src/ipc/test/ipc_test.cpp index c01ef1964c1..a350d60b5d8 100644 --- a/src/test/ipc_test.cpp +++ b/src/ipc/test/ipc_test.cpp @@ -8,9 +8,9 @@ #include #include #include -#include -#include -#include +#include +#include +#include #include #include diff --git a/src/test/ipc_test.h b/src/ipc/test/ipc_test.h similarity index 88% rename from src/test/ipc_test.h rename to src/ipc/test/ipc_test.h index 2304d8a4c0d..1d5254fe9f1 100644 --- a/src/test/ipc_test.h +++ b/src/ipc/test/ipc_test.h @@ -2,8 +2,8 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -#ifndef BITCOIN_TEST_IPC_TEST_H -#define BITCOIN_TEST_IPC_TEST_H +#ifndef BITCOIN_IPC_TEST_IPC_TEST_H +#define BITCOIN_IPC_TEST_IPC_TEST_H #include #include