Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 0 additions & 16 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Comment on lines -329 to -334
Copy link
Contributor

Choose a reason for hiding this comment

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

In commit "cmake, test: Improve locality of bitcoin_ipc_test library description" (f26c8b0)

I think this comment is still useful to keep because otherwise there is no explanation of why bitcoin_ipc_test in defined src/ipc/ instead of src/ipc/test where it would make more sense.

Comment would just need to be tweaked slightly to be kept: src/CMakeLists.txt -> src/ipc/CMakeLists.txt, src/test/CMakeLists.txt -> src/ipc/test/CMakeLists.txt, and src/test/ to src/ipc/test/.

One of the things I dislike most about working with our build code is that I see a lot of unexpected things done with no explanation and it's not clear what those things were done intentionally or are accidental sources of complexity that could be cleaned up. I think it is better to call out inconsistencies like this and make intent clear than try to make code that is doing something unusual appear normal.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks! The comment has been restored and adjusted.

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
Expand Down
25 changes: 24 additions & 1 deletion src/ipc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
12 changes: 12 additions & 0 deletions src/ipc/test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# 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/.

# Do not use generator expressions in test sources because the
# SOURCES property is processed to gather test suite macros.
target_sources(test_bitcoin
PRIVATE
ipc_tests.cpp
)

target_link_libraries(test_bitcoin bitcoin_ipc_test bitcoin_ipc)
6 changes: 3 additions & 3 deletions src/test/ipc_test.capnp → src/ipc/test/ipc_test.capnp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions src/test/ipc_test.cpp → src/ipc/test/ipc_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand Down
6 changes: 3 additions & 3 deletions src/test/ipc_test.h → src/ipc/test/ipc_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -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
8 changes: 4 additions & 4 deletions src/test/ipc_test_types.h → src/ipc/test/ipc_test_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion src/test/ipc_tests.cpp → src/ipc/test/ipc_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
3 changes: 0 additions & 3 deletions src/test/.clang-tidy.in

This file was deleted.

15 changes: 1 addition & 14 deletions src/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -168,20 +168,7 @@ if(ENABLE_WALLET)
endif()

if(ENABLE_IPC)
target_link_libraries(bitcoin_ipc_test
PRIVATE
core_interface
univalue
Boost::headers
)

target_sources(test_bitcoin
PRIVATE
ipc_tests.cpp
)
target_link_libraries(test_bitcoin bitcoin_ipc_test bitcoin_ipc)

configure_file(.clang-tidy.in .clang-tidy USE_SOURCE_PERMISSIONS COPYONLY)
add_subdirectory(${PROJECT_SOURCE_DIR}/src/ipc/test ipc)
endif()

function(add_boost_test source_file)
Expand Down
Loading