Commit fe837b7f authored by Florian Franzen's avatar Florian Franzen
Browse files

cpp-libp2p: f075370 -> 0.0.2-p0

parent aa1fdd3a
......@@ -7,31 +7,35 @@
, protobuf
, openssl
, microsoft_gsl_cmake
, spdlog_cmake
, soralog
, boost_di
, tsl_hat_trie
, sqlite-modern-cpp
, c-ares
, withTests ? false
}:
stdenv.mkDerivation rec {
name = "cpp-libp2p-${lib.substring 0 7 version}";
version = "f075370398d3ddd444351e114d9c261cd3af244f";
version = "a8d9f98cd7b7a2ac82c962ecb2183f9b362395ce";
src = fetchFromGitHub {
owner = "soramitsu";
repo = "cpp-libp2p";
rev = "${version}";
sha256 = "05f77cq3ln834w5dx8hc6jvp67d15lhacx8j498zzx5d6hp1avcm";
rev = version;
sha256 = "0dqgf3kpdad6fljbb97dnv90b034ismng5ngfrbkw3yfjcjkinlr";
};
patches = [
patches = [
./dependencies.patch
./protobuf_path.patch
./yaml-cpp.patch
] ++ lib.optionals withTests [
./test-cares.patch
];
nativeBuildInputs = [
cmake
cmake
];
buildInputs = [
......@@ -48,13 +52,18 @@ stdenv.mkDerivation rec {
protobuf
boost172
spdlog_cmake
soralog
c-ares.cmake-config
];
cmakeFlags = [
doCheck = withTests;
cmakeFlags = [
"-DHUNTER_ENABLED=false"
# Tests fail in sandbox without network access
"-DTESTING=off"
"-DTESTING=${lib.boolToString withTests}"
"-DEXAMPLES=false"
"-DEXPOSE_MOCKS=true"
];
}
......
diff --git a/cmake/functions.cmake b/cmake/functions.cmake
index 778eb16..cc25e6f 100644
--- a/cmake/functions.cmake
+++ b/cmake/functions.cmake
@@ -44,74 +44,33 @@ function(add_flag flag)
endif ()
endfunction()
-function(compile_proto_to_cpp PROTO_LIBRARY_NAME PB_H PB_CC PROTO)
- get_target_property(Protobuf_INCLUDE_DIR protobuf::libprotobuf INTERFACE_INCLUDE_DIRECTORIES)
- get_target_property(Protobuf_PROTOC_EXECUTABLE protobuf::protoc IMPORTED_LOCATION_RELEASE)
-
- if (NOT Protobuf_PROTOC_EXECUTABLE)
- message(FATAL_ERROR "Protobuf_PROTOC_EXECUTABLE is empty")
- endif ()
- if (NOT Protobuf_INCLUDE_DIR)
- message(FATAL_ERROR "Protobuf_INCLUDE_DIR is empty")
- endif ()
-
- get_filename_component(PROTO_ABS "${PROTO}" REALPATH)
- # get relative (to CMAKE_BINARY_DIR) path of current proto file
- file(RELATIVE_PATH SCHEMA_REL "${CMAKE_BINARY_DIR}/src" "${CMAKE_CURRENT_BINARY_DIR}")
-
- set(SCHEMA_OUT_DIR ${CMAKE_BINARY_DIR}/pb/${PROTO_LIBRARY_NAME}/generated)
- file(MAKE_DIRECTORY ${SCHEMA_OUT_DIR})
-
- string(REGEX REPLACE "\\.proto$" ".pb.h" GEN_PB_HEADER ${PROTO})
- string(REGEX REPLACE "\\.proto$" ".pb.cc" GEN_PB ${PROTO})
-
- set(GEN_COMMAND ${Protobuf_PROTOC_EXECUTABLE})
- set(GEN_ARGS ${Protobuf_INCLUDE_DIR})
+# Collect all generated targets
+add_custom_target(generated
+ COMMENT "Building generated files..."
+)
- set(OUT_HPP ${SCHEMA_OUT_DIR}/${SCHEMA_REL}/${GEN_PB_HEADER})
- set(OUT_CPP ${SCHEMA_OUT_DIR}/${SCHEMA_REL}/${GEN_PB})
+# Reset import dirs before first run TODO: Reset to "${PROJECT_SOURCE_DIR}/src"?
+set(Protobuf_IMPORT_DIRS "" CACHE INTERNAL "List of all protobuf import directories")
- set(GENERATION_DIR ${SCHEMA_OUT_DIR}/${SCHEMA_REL})
+macro(add_proto_library NAME)
+ find_package(Protobuf REQUIRED)
- add_custom_command(
- OUTPUT ${OUT_HPP} ${OUT_CPP}
- COMMAND ${GEN_COMMAND}
- ARGS -I${PROJECT_SOURCE_DIR}/src -I${GEN_ARGS} --cpp_out=${SCHEMA_OUT_DIR} ${PROTO_ABS}
- WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
- DEPENDS protobuf::protoc
- VERBATIM
+ set(Protobuf_IMPORT_DIRS "${Protobuf_IMPORT_DIRS}\;${CMAKE_CURRENT_SOURCE_DIR}"
+ CACHE INTERNAL "List of all protobuf import directories"
)
- set(${PB_H} ${SCHEMA_OUT_DIR}/${SCHEMA_REL}/${GEN_PB_HEADER} PARENT_SCOPE)
- set(${PB_CC} ${SCHEMA_OUT_DIR}/${SCHEMA_REL}/${GEN_PB} PARENT_SCOPE)
-endfunction()
+ protobuf_generate_cpp(SOURCES HEADERS ${ARGN})
-add_custom_target(generated
- COMMENT "Building generated files..."
- )
+ add_library(${NAME} ${SOURCES} ${HEADERS})
+ target_link_libraries(${NAME} protobuf::libprotobuf)
-function(add_proto_library NAME)
- set(SOURCES "")
- foreach (PROTO IN ITEMS ${ARGN})
- compile_proto_to_cpp(${NAME} H C ${PROTO})
- list(APPEND SOURCES ${H} ${C})
- endforeach ()
-
- add_library(${NAME}
- ${SOURCES}
- )
- target_link_libraries(${NAME}
- protobuf::libprotobuf
- )
target_include_directories(${NAME} PUBLIC
- # required for common targets
- $<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/pb/${NAME}>
- # required for compiling proto targets
- $<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/pb/${NAME}/generated>
- )
+ $<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/src>
+ $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
+ )
disable_clang_tidy(${NAME})
libp2p_install(${NAME})
add_dependencies(generated ${NAME})
-endfunction()
+endmacro()
diff --git a/src/crypto/key_marshaller/key_marshaller_impl.cpp b/src/crypto/key_marshaller/key_marshaller_impl.cpp
index 99d6543..1282aef 100644
--- a/src/crypto/key_marshaller/key_marshaller_impl.cpp
+++ b/src/crypto/key_marshaller/key_marshaller_impl.cpp
@@ -5,7 +5,7 @@
#include <libp2p/crypto/key_marshaller/key_marshaller_impl.hpp>
-#include <generated/crypto/protobuf/keys.pb.h>
+#include <crypto/protobuf/keys.pb.h>
#include <libp2p/crypto/common.hpp>
#include <libp2p/crypto/crypto_provider.hpp>
diff --git a/src/protocol/gossip/impl/message_builder.cpp b/src/protocol/gossip/impl/message_builder.cpp
index 0d6d337..58ceaff 100644
--- a/src/protocol/gossip/impl/message_builder.cpp
+++ b/src/protocol/gossip/impl/message_builder.cpp
@@ -7,7 +7,7 @@
#include <libp2p/multi/uvarint.hpp>
-#include <generated/protocol/gossip/protobuf/rpc.pb.h>
+#include <protocol/gossip/protobuf/rpc.pb.h>
namespace libp2p::protocol::gossip {
diff --git a/src/protocol/gossip/impl/message_parser.cpp b/src/protocol/gossip/impl/message_parser.cpp
index 871c251..162d749 100644
--- a/src/protocol/gossip/impl/message_parser.cpp
+++ b/src/protocol/gossip/impl/message_parser.cpp
@@ -7,7 +7,7 @@
#include <libp2p/protocol/gossip/impl/message_receiver.hpp>
-#include <generated/protocol/gossip/protobuf/rpc.pb.h>
+#include <protocol/gossip/protobuf/rpc.pb.h>
namespace libp2p::protocol::gossip {
diff --git a/src/protocol/identify/identify_delta.cpp b/src/protocol/identify/identify_delta.cpp
index 2976629..d93cbc7 100644
--- a/src/protocol/identify/identify_delta.cpp
+++ b/src/protocol/identify/identify_delta.cpp
@@ -10,7 +10,7 @@
#include <libp2p/basic/protobuf_message_read_writer.hpp>
#include <libp2p/protocol/identify/utils.hpp>
-#include <generated/protocol/identify/protobuf/identify.pb.h>
+#include <protocol/identify/protobuf/identify.pb.h>
namespace {
const std::string kIdentifyDeltaProtocol = "/p2p/id/delta/1.0.0";
diff --git a/src/protocol/identify/identify_msg_processor.cpp b/src/protocol/identify/identify_msg_processor.cpp
index 0cf678c..3b9b55d 100644
--- a/src/protocol/identify/identify_msg_processor.cpp
+++ b/src/protocol/identify/identify_msg_processor.cpp
@@ -7,7 +7,7 @@
#include <tuple>
-#include <generated/protocol/identify/protobuf/identify.pb.h>
+#include <protocol/identify/protobuf/identify.pb.h>
#include <boost/assert.hpp>
#include <libp2p/basic/protobuf_message_read_writer.hpp>
#include <libp2p/network/network.hpp>
diff --git a/src/protocol/kademlia/impl/kad_message.cpp b/src/protocol/kademlia/impl/kad_message.cpp
index 626fca8..baba40d 100644
--- a/src/protocol/kademlia/impl/kad_message.cpp
+++ b/src/protocol/kademlia/impl/kad_message.cpp
@@ -6,7 +6,7 @@
#include <libp2p/multi/uvarint.hpp>
#include <libp2p/protocol/kademlia/impl/kad_message.hpp>
-#include <generated/protocol/kademlia/protobuf/kad.pb.h>
+#include <protocol/kademlia/protobuf/kad.pb.h>
namespace libp2p::protocol::kademlia {
diff --git a/src/security/noise/handshake_message_marshaller_impl.cpp b/src/security/noise/handshake_message_marshaller_impl.cpp
index 53eb843..d0a83af 100644
--- a/src/security/noise/handshake_message_marshaller_impl.cpp
+++ b/src/security/noise/handshake_message_marshaller_impl.cpp
@@ -5,7 +5,7 @@
#include <libp2p/security/noise/handshake_message_marshaller_impl.hpp>
-#include <generated/security/noise/protobuf/noise.pb.h>
+#include <security/noise/protobuf/noise.pb.h>
OUTCOME_CPP_DEFINE_CATEGORY(libp2p::security::noise,
HandshakeMessageMarshallerImpl::Error, e) {
using E = libp2p::security::noise::HandshakeMessageMarshallerImpl::Error;
diff --git a/src/security/plaintext/exchange_message_marshaller_impl.cpp b/src/security/plaintext/exchange_message_marshaller_impl.cpp
index 7ca75c3..bae433e 100644
--- a/src/security/plaintext/exchange_message_marshaller_impl.cpp
+++ b/src/security/plaintext/exchange_message_marshaller_impl.cpp
@@ -5,7 +5,7 @@
#include <libp2p/security/plaintext/exchange_message_marshaller_impl.hpp>
-#include <generated/security/plaintext/protobuf/plaintext.pb.h>
+#include <security/plaintext/protobuf/plaintext.pb.h>
OUTCOME_CPP_DEFINE_CATEGORY(libp2p::security::plaintext,
ExchangeMessageMarshallerImpl::Error, e) {
diff --git a/src/security/plaintext/plaintext.cpp b/src/security/plaintext/plaintext.cpp
index a78ffd9..969f165 100644
--- a/src/security/plaintext/plaintext.cpp
+++ b/src/security/plaintext/plaintext.cpp
@@ -7,7 +7,7 @@
#include <functional>
-#include <generated/security/plaintext/protobuf/plaintext.pb.h>
+#include <security/plaintext/protobuf/plaintext.pb.h>
#include <libp2p/basic/protobuf_message_read_writer.hpp>
#include <libp2p/peer/peer_id.hpp>
#include <libp2p/security/error.hpp>
diff --git a/src/security/plaintext/protobuf/plaintext.proto b/src/security/plaintext/protobuf/plaintext.proto
index 7f62ecf..da24f42 100644
--- a/src/security/plaintext/protobuf/plaintext.proto
+++ b/src/security/plaintext/protobuf/plaintext.proto
@@ -1,6 +1,6 @@
syntax = "proto2";
-import "crypto/protobuf/keys.proto";
+import "keys.proto";
package libp2p.security.plaintext.protobuf;
diff --git a/src/security/secio/exchange_message_marshaller_impl.cpp b/src/security/secio/exchange_message_marshaller_impl.cpp
index dbdc1db..99a89f6 100644
--- a/src/security/secio/exchange_message_marshaller_impl.cpp
+++ b/src/security/secio/exchange_message_marshaller_impl.cpp
@@ -5,7 +5,7 @@
#include <libp2p/security/secio/exchange_message_marshaller_impl.hpp>
-#include <generated/security/secio/protobuf/secio.pb.h>
+#include <security/secio/protobuf/secio.pb.h>
OUTCOME_CPP_DEFINE_CATEGORY(libp2p::security::secio,
ExchangeMessageMarshallerImpl::Error, e) {
diff --git a/src/security/secio/propose_message_marshaller_impl.cpp b/src/security/secio/propose_message_marshaller_impl.cpp
index 03c9450..84157fc 100644
--- a/src/security/secio/propose_message_marshaller_impl.cpp
+++ b/src/security/secio/propose_message_marshaller_impl.cpp
@@ -5,7 +5,7 @@
#include <libp2p/security/secio/propose_message_marshaller_impl.hpp>
-#include <generated/security/secio/protobuf/secio.pb.h>
+#include <security/secio/protobuf/secio.pb.h>
OUTCOME_CPP_DEFINE_CATEGORY(libp2p::security::secio,
ProposeMessageMarshallerImpl::Error, e) {
diff --git a/src/security/secio/secio.cpp b/src/security/secio/secio.cpp
index cd0e2b6..0223197 100644
--- a/src/security/secio/secio.cpp
+++ b/src/security/secio/secio.cpp
@@ -5,7 +5,7 @@
#include <libp2p/security/secio/secio.hpp>
-#include <generated/security/secio/protobuf/secio.pb.h>
+#include <security/secio/protobuf/secio.pb.h>
#include <libp2p/basic/protobuf_message_read_writer.hpp>
#include <libp2p/crypto/sha/sha256.hpp>
#include <libp2p/security/error.hpp>
diff --git a/src/security/secio/secio_dialer.cpp b/src/security/secio/secio_dialer.cpp
index 58e640a..e1969a8 100644
--- a/src/security/secio/secio_dialer.cpp
+++ b/src/security/secio/secio_dialer.cpp
@@ -5,7 +5,7 @@
#include <libp2p/security/secio/secio_dialer.hpp>
-#include <generated/security/secio/protobuf/secio.pb.h>
+#include <security/secio/protobuf/secio.pb.h>
#include <libp2p/basic/message_read_writer_bigendian.hpp>
#include <libp2p/basic/protobuf_message_read_writer.hpp>
#include <libp2p/crypto/sha/sha256.hpp>
diff --git a/test/libp2p/protocol/identify_delta_test.cpp b/test/libp2p/protocol/identify_delta_test.cpp
index 98d1d01..e7dfafa 100644
--- a/test/libp2p/protocol/identify_delta_test.cpp
+++ b/test/libp2p/protocol/identify_delta_test.cpp
@@ -5,7 +5,7 @@
#include <libp2p/protocol/identify/identify_delta.hpp>
-#include <generated/protocol/identify/protobuf/identify.pb.h>
+#include <protocol/identify/protobuf/identify.pb.h>
#include <gtest/gtest.h>
#include <libp2p/common/literals.hpp>
#include <libp2p/multi/uvarint.hpp>
diff --git a/test/libp2p/protocol/identify_test.cpp b/test/libp2p/protocol/identify_test.cpp
index d70ee87..d57eeb2 100644
--- a/test/libp2p/protocol/identify_test.cpp
+++ b/test/libp2p/protocol/identify_test.cpp
@@ -7,7 +7,7 @@
#include <vector>
-#include <generated/protocol/identify/protobuf/identify.pb.h>
+#include <protocol/identify/protobuf/identify.pb.h>
#include <gtest/gtest.h>
#include <libp2p/common/literals.hpp>
#include <libp2p/multi/uvarint.hpp>
diff --git a/test/libp2p/security/plaintext_exchange_message_marshaller_test.cpp b/test/libp2p/security/plaintext_exchange_message_marshaller_test.cpp
index 1febe8d..f5a49f7 100644
--- a/test/libp2p/security/plaintext_exchange_message_marshaller_test.cpp
+++ b/test/libp2p/security/plaintext_exchange_message_marshaller_test.cpp
@@ -5,7 +5,7 @@
#include <gtest/gtest.h>
-#include <generated/security/plaintext/protobuf/plaintext.pb.h>
+#include <security/plaintext/protobuf/plaintext.pb.h>
#include <libp2p/crypto/key.hpp>
#include <libp2p/peer/peer_id.hpp>
#include <libp2p/security/plaintext/exchange_message_marshaller_impl.hpp>
diff --git a/test/mock/libp2p/security/exchange_message_marshaller_mock.hpp b/test/mock/libp2p/security/exchange_message_marshaller_mock.hpp
index 68909bd..0d7b905 100644
--- a/test/mock/libp2p/security/exchange_message_marshaller_mock.hpp
+++ b/test/mock/libp2p/security/exchange_message_marshaller_mock.hpp
@@ -6,7 +6,7 @@
#ifndef LIBP2P_EXCHANGE_MESSAGE_MARSHALLER_MOCK_HPP
#define LIBP2P_EXCHANGE_MESSAGE_MARSHALLER_MOCK_HPP
-#include <generated/security/plaintext/protobuf/plaintext.pb.h>
+#include <security/plaintext/protobuf/plaintext.pb.h>
#include <gmock/gmock.h>
#include "libp2p/security/plaintext/exchange_message.hpp"
#include "libp2p/security/plaintext/exchange_message_marshaller.hpp"
diff --git a/test/libp2p/injector/CMakeLists.txt b/test/libp2p/injector/CMakeLists.txt
index 9d8c0a3..77b5a56 100644
--- a/test/libp2p/injector/CMakeLists.txt
+++ b/test/libp2p/injector/CMakeLists.txt
@@ -7,6 +7,7 @@ addtest(network_injector_test
target_link_libraries(network_injector_test
Boost::Boost.DI
p2p_default_network
+ p2p_cares
)
diff --git a/src/log/CMakeLists.txt b/src/log/CMakeLists.txt
index 8590bc0..a51aa2e 100644
--- a/src/log/CMakeLists.txt
+++ b/src/log/CMakeLists.txt
@@ -11,5 +11,4 @@ target_link_libraries(p2p_logger
soralog::soralog
soralog::fallback_configurator
soralog::configurator_yaml
- yaml-cpp::yaml-cpp
)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment