Skip to content

Commit a2f28e4

Browse files
committed
Squashed 'src/ipc/libmultiprocess/' content from commit 35944ffd23fa
git-subtree-dir: src/ipc/libmultiprocess git-subtree-split: 35944ffd23fa26652b82210351d50e896ce16c8f
0 parents  commit a2f28e4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+5878
-0
lines changed

.clang-tidy

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
Checks: '
2+
-*,
3+
bugprone-*,
4+
-bugprone-easily-swappable-parameters,
5+
-bugprone-exception-escape,
6+
-bugprone-move-forwarding-reference,
7+
-bugprone-narrowing-conversions,
8+
-bugprone-reserved-identifier,
9+
misc-*,
10+
-misc-non-private-member-variables-in-classes,
11+
-misc-no-recursion,
12+
-misc-unconventional-assign-operator,
13+
-misc-unused-parameters,
14+
-misc-use-anonymous-namespace,
15+
modernize-*,
16+
-modernize-avoid-c-arrays,
17+
-modernize-concat-nested-namespaces,
18+
-modernize-deprecated-headers,
19+
-modernize-use-nodiscard,
20+
-modernize-use-trailing-return-type,
21+
-modernize-use-using,
22+
performance-*,
23+
-performance-avoid-endl,
24+
-performance-noexcept-move-constructor,
25+
readability-*,
26+
-readability-braces-around-statements,
27+
-readability-convert-member-functions-to-static,
28+
-readability-else-after-return,
29+
-readability-function-cognitive-complexity,
30+
-readability-identifier-length,
31+
-readability-implicit-bool-conversion,
32+
-readability-inconsistent-declaration-parameter-name,
33+
-readability-magic-numbers,
34+
-readability-named-parameter,
35+
-readability-uppercase-literal-suffix,
36+
-readability-use-anyofallof,
37+
'
38+
CheckOptions:
39+
- key: modernize-use-override.IgnoreDestructors
40+
value: true
41+
HeaderFilterRegex: 'example/calculator.h|example/init.h|example/printer.h|include/mp/proxy-io.h|include/mp/proxy-types.h|include/mp/proxy.h|include/mp/util.h|test/mp/test/foo-types.h|test/mp/test/foo.h'

CMakeLists.txt

Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
1+
# Copyright (c) 2019 The Bitcoin Core developers
2+
# Distributed under the MIT software license, see the accompanying
3+
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
4+
5+
cmake_minimum_required(VERSION 3.12)
6+
7+
project("Libmultiprocess" CXX)
8+
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
9+
set(CMAKE_CXX_STANDARD 20)
10+
set(CMAKE_CXX_STANDARD_REQUIRED YES)
11+
endif()
12+
13+
include("cmake/compat_find.cmake")
14+
15+
find_package(CapnProto REQUIRED)
16+
find_package(Threads REQUIRED)
17+
18+
option(Libmultiprocess_ENABLE_CLANG_TIDY "Run clang-tidy with the compiler." OFF)
19+
if(Libmultiprocess_ENABLE_CLANG_TIDY)
20+
find_program(CLANG_TIDY_EXECUTABLE NAMES clang-tidy)
21+
if(NOT CLANG_TIDY_EXECUTABLE)
22+
message(FATAL_ERROR "Libmultiprocess_ENABLE_CLANG_TIDY is ON but clang-tidy is not found.")
23+
endif()
24+
set(CMAKE_CXX_CLANG_TIDY "${CLANG_TIDY_EXECUTABLE}")
25+
endif()
26+
27+
set(MPGEN_EXECUTABLE "" CACHE FILEPATH "If specified, should be full path to an external mpgen binary to use rather than the one built internally.")
28+
29+
include("cmake/compat_config.cmake")
30+
include("cmake/pthread_checks.cmake")
31+
include(GNUInstallDirs)
32+
33+
# Set MP_INCLUDE_DIR as a global property so target_capnp_sources function can
34+
# use it, and its callers don't need to specify the include directory manually
35+
# to avoid "error: Import failed: /mp/proxy.capnp" failures from capnproto.
36+
set_property(GLOBAL PROPERTY MP_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include")
37+
38+
# Set a convenience variable for subdirectories.
39+
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
40+
set(MP_STANDALONE TRUE)
41+
include(CTest)
42+
else()
43+
set(MP_STANDALONE FALSE)
44+
endif()
45+
46+
# Prevent include directories from parent project from leaking into this one.
47+
set_property(DIRECTORY PROPERTY INCLUDE_DIRECTORIES "")
48+
49+
# Generated C++ preprocessor defines
50+
configure_file(include/mp/config.h.in "${CMAKE_CURRENT_BINARY_DIR}/include/mp/config.h")
51+
52+
# Generated C++ Capn'Proto schema files
53+
capnp_generate_cpp(MP_PROXY_SRCS MP_PROXY_HDRS include/mp/proxy.capnp)
54+
55+
# util library
56+
add_library(mputil OBJECT src/mp/util.cpp)
57+
target_include_directories(mputil PRIVATE
58+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
59+
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>)
60+
target_link_libraries(mputil PUBLIC CapnProto::kj)
61+
62+
# libmultiprocess.a runtime library
63+
set(MP_PUBLIC_HEADERS
64+
${MP_PROXY_HDRS}
65+
include/mp/proxy-io.h
66+
include/mp/proxy-types.h
67+
include/mp/proxy.h
68+
include/mp/type-char.h
69+
include/mp/type-chrono.h
70+
include/mp/type-context.h
71+
include/mp/type-data.h
72+
include/mp/type-decay.h
73+
include/mp/type-exception.h
74+
include/mp/type-function.h
75+
include/mp/type-interface.h
76+
include/mp/type-map.h
77+
include/mp/type-message.h
78+
include/mp/type-number.h
79+
include/mp/type-optional.h
80+
include/mp/type-pair.h
81+
include/mp/type-pointer.h
82+
include/mp/type-set.h
83+
include/mp/type-string.h
84+
include/mp/type-struct.h
85+
include/mp/type-threadmap.h
86+
include/mp/type-tuple.h
87+
include/mp/type-vector.h
88+
include/mp/type-void.h
89+
include/mp/util.h)
90+
add_library(multiprocess STATIC
91+
${MP_PROXY_SRCS}
92+
${MP_PUBLIC_HEADERS}
93+
src/mp/proxy.cpp
94+
$<TARGET_OBJECTS:mputil>)
95+
add_library(Libmultiprocess::multiprocess ALIAS multiprocess)
96+
target_include_directories(multiprocess PUBLIC
97+
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>
98+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
99+
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
100+
target_link_libraries(multiprocess PUBLIC CapnProto::capnp)
101+
target_link_libraries(multiprocess PUBLIC CapnProto::capnp-rpc)
102+
target_link_libraries(multiprocess PUBLIC CapnProto::kj)
103+
target_link_libraries(multiprocess PUBLIC CapnProto::kj-async)
104+
set_target_properties(multiprocess PROPERTIES
105+
PUBLIC_HEADER "${MP_PUBLIC_HEADERS}")
106+
install(TARGETS multiprocess EXPORT LibTargets
107+
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT lib
108+
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/mp COMPONENT lib)
109+
110+
# mpgen code generator
111+
add_executable(mpgen src/mp/gen.cpp $<TARGET_OBJECTS:mputil>)
112+
add_executable(Libmultiprocess::mpgen ALIAS mpgen)
113+
target_include_directories(mpgen PRIVATE $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>)
114+
target_include_directories(mpgen PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
115+
target_link_libraries(mpgen PRIVATE CapnProto::capnp)
116+
target_link_libraries(mpgen PRIVATE CapnProto::capnp-rpc)
117+
target_link_libraries(mpgen PRIVATE CapnProto::capnpc)
118+
target_link_libraries(mpgen PRIVATE CapnProto::kj)
119+
target_link_libraries(mpgen PRIVATE Threads::Threads)
120+
set_target_properties(mpgen PROPERTIES
121+
INSTALL_RPATH_USE_LINK_PATH TRUE)
122+
set_target_properties(mpgen PROPERTIES
123+
PUBLIC_HEADER include/mp/proxy.capnp)
124+
install(TARGETS mpgen EXPORT BinTargets
125+
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT bin
126+
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/mp COMPONENT bin)
127+
128+
# makefile include to invoke mpgen code generator, for downstream Make projects
129+
install(FILES "include/mpgen.mk"
130+
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} COMPONENT bin)
131+
132+
# pkg-config module to build against libmultiprocess library, for downstream autoconf projects
133+
configure_file(pkgconfig/libmultiprocess.pc.in "${CMAKE_CURRENT_BINARY_DIR}/pkgconfig/libmultiprocess.pc" @ONLY)
134+
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/pkgconfig/libmultiprocess.pc"
135+
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig COMPONENT lib)
136+
137+
# cmake include to invoke mpgen code generator, for downstream CMake projects
138+
install(
139+
FILES
140+
${CMAKE_CURRENT_SOURCE_DIR}/cmake/TargetCapnpSources.cmake
141+
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/Libmultiprocess COMPONENT bin)
142+
143+
# CMake target import files, for downstream CMake projects
144+
install(EXPORT BinTargets
145+
NAMESPACE Libmultiprocess::
146+
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/Libmultiprocess COMPONENT bin)
147+
install(EXPORT LibTargets
148+
NAMESPACE Libmultiprocess::
149+
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/Libmultiprocess COMPONENT lib)
150+
151+
# CMake find_package config file, for downstream CMake projects
152+
include(CMakePackageConfigHelpers)
153+
configure_package_config_file(
154+
${PROJECT_SOURCE_DIR}/cmake/Config.cmake.in
155+
LibmultiprocessConfig.cmake
156+
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/Libmultiprocess
157+
NO_SET_AND_CHECK_MACRO)
158+
install(
159+
FILES
160+
${CMAKE_CURRENT_BINARY_DIR}/LibmultiprocessConfig.cmake
161+
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/Libmultiprocess
162+
COMPONENT common)
163+
164+
# Makefile targets to support "make install-bin" "make install-lib"
165+
add_custom_target(install-bin
166+
COMMAND ${CMAKE_COMMAND} -DCOMPONENT=bin -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_install.cmake
167+
COMMAND ${CMAKE_COMMAND} -DCOMPONENT=common -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_install.cmake
168+
VERBATIM)
169+
add_dependencies(install-bin mpgen)
170+
add_custom_target(install-lib
171+
COMMAND ${CMAKE_COMMAND} -DCOMPONENT=lib -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_install.cmake
172+
COMMAND ${CMAKE_COMMAND} -DCOMPONENT=common -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_install.cmake
173+
VERBATIM)
174+
add_dependencies(install-lib multiprocess)
175+
176+
# Example and test subdirectories
177+
add_subdirectory(example EXCLUDE_FROM_ALL)
178+
add_subdirectory(test EXCLUDE_FROM_ALL)

COPYING

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2009-2019 The Bitcoin Core developers
4+
Copyright (c) 2009-2019 Bitcoin Developers
5+
6+
Permission is hereby granted, free of charge, to any person obtaining a copy
7+
of this software and associated documentation files (the "Software"), to deal
8+
in the Software without restriction, including without limitation the rights
9+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
copies of the Software, and to permit persons to whom the Software is
11+
furnished to do so, subject to the following conditions:
12+
13+
The above copyright notice and this permission notice shall be included in
14+
all copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22+
THE SOFTWARE.

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# libmultiprocess
2+
3+
`libmultiprocess` is a C++ library and code generator making it easy to call functions and reference objects in different processes.
4+
5+
For more information see the [usage instructions](doc/usage.md), [installation instructions](doc/install.md), or [design documentation](doc/design.md).
6+
7+
If you have any questions, comments, or feedback, please submit an [issue](https://github.com/bitcoin-core/libmultiprocess/issues/new).
8+
Duplicate issues are perfectly fine and all discussion about the project is welcome, since there isn't another discussion forum currently.

cmake/Config.cmake.in

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
@PACKAGE_INIT@
2+
3+
# CMake find_package compatible package file, for downstream CMake projects
4+
#
5+
# Based on https://cmake.org/cmake/help/latest/guide/importing-exporting/index.html#adding-components
6+
7+
set(_Libmultiprocess_supported_components Bin Lib)
8+
9+
# If no components specified, include all components.
10+
list(LENGTH ${CMAKE_FIND_PACKAGE_NAME}_FIND_COMPONENTS ${CMAKE_FIND_PACKAGE_NAME}_FIND_COMPONENTS_len)
11+
if(${CMAKE_FIND_PACKAGE_NAME}_FIND_COMPONENTS_len EQUAL 0)
12+
set(${CMAKE_FIND_PACKAGE_NAME}_FIND_COMPONENTS ${_Libmultiprocess_supported_components})
13+
endif()
14+
15+
if ("Bin" IN_LIST ${CMAKE_FIND_PACKAGE_NAME}_FIND_COMPONENTS)
16+
include("${CMAKE_CURRENT_LIST_DIR}/TargetCapnpSources.cmake")
17+
endif()
18+
19+
if ("Lib" IN_LIST ${CMAKE_FIND_PACKAGE_NAME}_FIND_COMPONENTS)
20+
# Setting FOUND_LIBATOMIC is needed on debian & ubuntu systems to work around bug in
21+
# their capnproto packages. See compat_find.cmake for a more complete explanation.
22+
set(FOUND_LIBATOMIC TRUE)
23+
include(CMakeFindDependencyMacro)
24+
find_dependency(CapnProto)
25+
endif()
26+
27+
foreach(_comp ${${CMAKE_FIND_PACKAGE_NAME}_FIND_COMPONENTS})
28+
if (NOT _comp IN_LIST _Libmultiprocess_supported_components)
29+
set(${CMAKE_FIND_PACKAGE_NAME}_FOUND False)
30+
set(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE "Unsupported component: ${_comp}")
31+
endif()
32+
include("${CMAKE_CURRENT_LIST_DIR}/${_comp}Targets.cmake")
33+
endforeach()

0 commit comments

Comments
 (0)