mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-09-12 21:52:53 +02:00
16bf05dea02 Merge bitcoin-core/libmultiprocess#302: refactor: rename EventLoop::m_num_clients to m_num_refs dd537da9e40 Merge bitcoin-core/libmultiprocess#301: test: recursive async IPC calls and cleanups 400291de000 Merge bitcoin-core/libmultiprocess#299: ci: remove libevent from Core CIs 092be515adf Merge bitcoin-core/libmultiprocess#285: Add ReadList helper 5b617880c51 Merge bitcoin-core/libmultiprocess#283: Add `makePool` method on `ThreadMap` d4998304154 refactor: rename EventLoop::m_num_clients to m_num_refs 6450345c985 type: reserve first when reading std::unordered_set 4d0f8db5f99 proxy: add ReadList helper and dedup map/set/vector read handlers 0e49d911867 Add `makePool` method on `ThreadMap` 5519f7f9485 test: recursive async IPC calls a29ceff40bc ci: remove libevent from Core CIs 8412fcdc659 Merge bitcoin-core/libmultiprocess#295: Mark Waiter m_cv as guarded by m_mutex 1593ee2d18a Merge bitcoin-core/libmultiprocess#294: test: Add passDouble smoke test 9885d7dd33c Merge bitcoin-core/libmultiprocess#286: proxy-client: fix TSan data race in clientDestroy fa35501c4f0 Mark Waiter m_cv as guarded by m_mutex faaedb11f8a test: Add passDouble smoke test 733c64318d1 Merge bitcoin-core/libmultiprocess#292: type-number: fix clang-tidy modernize-use-nullptr 9cc3479ab33 Merge bitcoin-core/libmultiprocess#291: cmake: Add `mp_headers` custom target 201abd9e3a5 Merge bitcoin-core/libmultiprocess#289: cmake: make target_capnp_sources use CURRENT dirs 99820c8aecb Merge bitcoin-core/libmultiprocess#279: doc: Add comments to FIELD_* constants in proxy.h 73b985540c5 Merge bitcoin-core/libmultiprocess#278: doc: Fix and expand design.md e7e91b2e23e Merge bitcoin-core/libmultiprocess#277: Add std::unordered_set support and a helper BuildList to dedup list build handlers 91a951f59ac tidy fix: modernize-use-nullptr 16362f42d01 cmake: Add `mp_headers` custom target 615a94fe3a2 cmake: document ONLY_CAPNP option in target_capnp_sources 90982f75c6b mpgen: iwyu changes required by previous commit 25bb3e67f39 proxy-client: fix TSan data race in clientDestroy 620f297f311 cmake: make target_capnp_sources use CURRENT dirs 9de4b885aa6 test: use camelCase + $Proxy.name for FooStruct fields 011b91793dd type: add std::unordered_set support 20d19b9644e proxy: add BuildList helper and dedup map/set/vector build handlers e863c6cdf61 doc: Add comments to FIELD_* constants in proxy.h 18db0ab9570 doc: Fix and expand design.md 61de6975362 Merge bitcoin-core/libmultiprocess#273: proxy-client: tolerate exceptions from remote destroy during cleanup 9cec9d6ca55 Merge bitcoin-core/libmultiprocess#243: mpgen: support primitive std::optional struct fields 4aaff113745 Merge bitcoin-core/libmultiprocess#238: cmake, ci: updates for recent nixpkgs 2ac55a56b58 Merge bitcoin-core/libmultiprocess#218: Better error and log messages 6de92e1c732 proxy-client: tolerate exceptions from remote destroy during cleanup 90be8354d47 test: regression for ~ProxyClient destroy after peer disconnect 3c69d125a17 Merge bitcoin-core/libmultiprocess#260: event loop: tolerate unexpected exceptions in `post()` callbacks b8a48c65e60 event loop: tolerate unexpected exceptions in `post()` callbacks f787863d2cd Merge bitcoin-core/libmultiprocess#270: doc: Bump version 10 > 11 a22f6029103 doc: Bump version 10 > 11 4eae445d6d8 debug: Add TypeName() function and log statements for Proxy objects being created and destroyed f326c5b1b7b logging: Add better logging on IPC server-side failures 6dbfa56a040 mpgen: support primitive std::optional struct fields 8d1277deb55 mpgen refactor: add AccessorType function db716bbcba7 mpgen refactor: Move field handling code to FieldList class db7acb3ce27 ci: Fix shell.nix compatibility with CMake 4.0 91a7759a9ab cmake: Fix IWYU in nix by adding CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES git-subtree-dir: src/ipc/libmultiprocess git-subtree-split: 16bf05dea02651f75733ff08531181aa774fc5a8
126 lines
5.0 KiB
CMake
126 lines
5.0 KiB
CMake
# 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/.
|
|
|
|
#[=[
|
|
|
|
target_capnp_sources
|
|
--------------------
|
|
|
|
This function adds build steps to generate C++ files from Cap'n Proto files
|
|
and build them as part of a specified target.
|
|
|
|
Arguments:
|
|
|
|
target: The name of the CMake target (e.g., a library or executable) to
|
|
which the generated source files will be added. This target must already
|
|
be defined elsewhere in the CMake scripts.
|
|
|
|
include_prefix: Absolute path indicating what portion of capnp source paths
|
|
should be used in relative #include statements in the generated C++
|
|
files. For example, if the .capnp path is /home/src/lib/schema.capnp
|
|
and include_prefix is /home/src, generated includes look like:
|
|
|
|
#include <lib/schema.capnp.h>
|
|
|
|
And if include_prefix is /home/src/lib, generated includes look like:
|
|
|
|
#include <schema.capnp.h>
|
|
|
|
Pass ${CMAKE_CURRENT_SOURCE_DIR} or a subdirectory of it to include files
|
|
relative to the current source directory (the typical usage).
|
|
|
|
Additional Unnamed Arguments:
|
|
|
|
After `target` and `include_prefix`, all unnamed arguments are treated as
|
|
paths to `.capnp` schema files. These should be paths relative to
|
|
${CMAKE_CURRENT_SOURCE_DIR}.
|
|
|
|
Optional Keyword Arguments:
|
|
|
|
IMPORT_PATHS: Specifies additional directories to search for imported
|
|
`.capnp` files.
|
|
|
|
ONLY_CAPNP: If specified, only the Cap'n Proto serialization files
|
|
(`.capnp.h`, `.capnp.c++`) are generated and compiled. The mpgen proxy
|
|
files (`.capnp.proxy-client.c++`, `.capnp.proxy-server.c++`,
|
|
`.capnp.proxy-types.c++`, etc.) are skipped. Useful when you need
|
|
Cap'n Proto serialization without the multiprocess RPC proxy
|
|
infrastructure.
|
|
|
|
Example:
|
|
# Assuming `my_library` is a target and `lib/` contains `.capnp` schema
|
|
# files with imports from `include/`.
|
|
target_capnp_sources(my_library "${CMAKE_CURRENT_SOURCE_DIR}"
|
|
lib/schema1.capnp lib/schema2.capnp
|
|
IMPORT_PATHS ${CMAKE_CURRENT_SOURCE_DIR}/include)
|
|
|
|
#]=]
|
|
|
|
function(target_capnp_sources target include_prefix)
|
|
cmake_parse_arguments(PARSE_ARGV 2
|
|
"TCS" # prefix
|
|
"ONLY_CAPNP" # options
|
|
"" # one_value_keywords
|
|
"IMPORT_PATHS" # multi_value_keywords
|
|
)
|
|
|
|
set(MPGEN_BINARY "")
|
|
if(MPGEN_EXECUTABLE)
|
|
set(MPGEN_BINARY "${MPGEN_EXECUTABLE}")
|
|
if(NOT EXISTS "${MPGEN_BINARY}")
|
|
message(FATAL_ERROR "MPGEN_EXECUTABLE: \"${MPGEN_BINARY}\" does not exist.")
|
|
endif()
|
|
elseif(TARGET Libmultiprocess::multiprocess)
|
|
set(MPGEN_BINARY Libmultiprocess::mpgen)
|
|
else()
|
|
message(FATAL_ERROR "No usable mpgen. Set MPGEN_EXECUTABLE or enable the internal target.")
|
|
endif()
|
|
|
|
get_property(mp_include_dir GLOBAL PROPERTY MP_INCLUDE_DIR)
|
|
set(generated_headers "")
|
|
foreach(capnp_file IN LISTS TCS_UNPARSED_ARGUMENTS)
|
|
add_custom_command(
|
|
OUTPUT ${capnp_file}.c++ ${capnp_file}.h ${capnp_file}.proxy-client.c++ ${capnp_file}.proxy-types.h ${capnp_file}.proxy-server.c++ ${capnp_file}.proxy-types.c++ ${capnp_file}.proxy.h
|
|
COMMAND ${MPGEN_BINARY} ${CMAKE_CURRENT_SOURCE_DIR} ${include_prefix} ${CMAKE_CURRENT_SOURCE_DIR}/${capnp_file} ${TCS_IMPORT_PATHS} ${mp_include_dir}
|
|
DEPENDS ${capnp_file}
|
|
VERBATIM
|
|
)
|
|
# Skip linting for capnp-generated files but keep it for mpgen-generated ones
|
|
set_source_files_properties(${capnp_file}.c++ PROPERTIES SKIP_LINTING TRUE) # Ignored before cmake 3.27
|
|
target_sources(${target} PRIVATE
|
|
${CMAKE_CURRENT_BINARY_DIR}/${capnp_file}.c++
|
|
)
|
|
if(NOT TCS_ONLY_CAPNP)
|
|
target_sources(${target} PRIVATE
|
|
${CMAKE_CURRENT_BINARY_DIR}/${capnp_file}.proxy-client.c++
|
|
${CMAKE_CURRENT_BINARY_DIR}/${capnp_file}.proxy-server.c++
|
|
${CMAKE_CURRENT_BINARY_DIR}/${capnp_file}.proxy-types.c++
|
|
)
|
|
endif()
|
|
list(APPEND generated_headers ${capnp_file}.h)
|
|
endforeach()
|
|
|
|
# Translate include_prefix from a source path to a binary path and add it as a
|
|
# target include directory.
|
|
set(build_include_prefix ${CMAKE_CURRENT_BINARY_DIR})
|
|
file(RELATIVE_PATH relative_path ${CMAKE_CURRENT_SOURCE_DIR} ${include_prefix})
|
|
if(relative_path)
|
|
string(APPEND build_include_prefix "/" "${relative_path}")
|
|
endif()
|
|
target_include_directories(${target} PUBLIC $<BUILD_INTERFACE:${build_include_prefix}> ${mp_include_dir})
|
|
|
|
if(TARGET Libmultiprocess::multiprocess)
|
|
target_link_libraries(${target} PRIVATE Libmultiprocess::multiprocess)
|
|
endif()
|
|
|
|
# Add a custom target that can be specified as a dependency of c++ targets
|
|
# that include generated headers. It can be necessary to specify these
|
|
# dependencies explicitly because while cmake detect dependencies of non
|
|
# generated files on generated headers, it does not reliably detect
|
|
# dependencies of generated headers on other generated headers.
|
|
if(NOT TARGET "${target}_headers")
|
|
add_custom_target("${target}_headers" DEPENDS ${generated_headers})
|
|
endif()
|
|
endfunction()
|