cmake, test: Improve locality of bitcoin_ipc_test library description

This commit is contained in:
Hennadii Stepanov
2025-11-05 21:39:58 +00:00
parent ae2e438b25
commit 866bbb98fd
8 changed files with 38 additions and 38 deletions

View File

@@ -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

View File

@@ -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)

View File

@@ -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

View File

@@ -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);

View File

@@ -8,9 +8,9 @@
#include <ipc/protocol.h>
#include <logging.h>
#include <mp/proxy-types.h>
#include <test/ipc_test.capnp.h>
#include <test/ipc_test.capnp.proxy.h>
#include <test/ipc_test.h>
#include <ipc/test/ipc_test.capnp.h>
#include <ipc/test/ipc_test.capnp.proxy.h>
#include <ipc/test/ipc_test.h>
#include <tinyformat.h>
#include <validation.h>

View File

@@ -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 <primitives/transaction.h>
#include <script/script.h>
@@ -27,4 +27,4 @@ void IpcPipeTest();
void IpcSocketPairTest();
void IpcSocketTest(const fs::path& datadir);
#endif // BITCOIN_TEST_IPC_TEST_H
#endif // BITCOIN_IPC_TEST_IPC_TEST_H

View File

@@ -2,11 +2,11 @@
// 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_TYPES_H
#define BITCOIN_TEST_IPC_TEST_TYPES_H
#ifndef BITCOIN_IPC_TEST_IPC_TEST_TYPES_H
#define BITCOIN_IPC_TEST_IPC_TEST_TYPES_H
#include <ipc/capnp/common-types.h>
#include <ipc/capnp/mining-types.h>
#include <test/ipc_test.capnp.h>
#include <ipc/test/ipc_test.capnp.h>
#endif // BITCOIN_TEST_IPC_TEST_TYPES_H
#endif // BITCOIN_IPC_TEST_IPC_TEST_TYPES_H

View File

@@ -3,7 +3,7 @@
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <ipc/process.h>
#include <test/ipc_test.h>
#include <ipc/test/ipc_test.h>
#include <test/util/setup_common.h>
#include <boost/test/unit_test.hpp>