From 7f9160bb6e4fb87495ddb39582028c199efda767 Mon Sep 17 00:00:00 2001 From: Jason Rhinelander Date: Wed, 20 May 2020 16:25:57 -0300 Subject: [PATCH] Untangle some interdependencies macOS doing a shared library build is not working without untangling some of the interdependencies. This commit does that, at least enough to get macOS to compile. This isn't the cleanest as currently implemented (we have some net/ things in `liblokinet-platform` and some in `liblokinet`, and likewise ev/vpnio.cpp is in `liblokinet` while the rest of `ev/*` is in `liblokinet-platform`). --- llarp/CMakeLists.txt | 32 ++++++++++++++++++-------------- llarp/exit/session.hpp | 1 + llarp/net/ip_packet.hpp | 2 +- llarp/service/protocol.hpp | 7 +------ llarp/service/protocol_type.hpp | 13 +++++++++++++ 5 files changed, 34 insertions(+), 21 deletions(-) create mode 100644 llarp/service/protocol_type.hpp diff --git a/llarp/CMakeLists.txt b/llarp/CMakeLists.txt index fdb201425..41270b359 100644 --- a/llarp/CMakeLists.txt +++ b/llarp/CMakeLists.txt @@ -1,10 +1,6 @@ include(Version) add_library(lokinet-util - config/config.cpp - config/definition.cpp - config/ini.cpp - config/key_manager.cpp ${CMAKE_CURRENT_BINARY_DIR}/constants/version.cpp util/bencode.cpp util/buffer.cpp @@ -41,13 +37,6 @@ target_link_libraries(lokinet-util PUBLIC filesystem date::date ) -if(TARGET curl) - target_link_libraries(lokinet-util PUBLIC curl) - target_compile_definitions(lokinet-util PRIVATE HAVE_CURL) - if(TARGET libcurl_external) - add_dependencies(lokinet-util libcurl_external) - endif() -endif() if(ANDROID) target_link_libraries(lokinet-util PUBLIC log) @@ -58,14 +47,15 @@ add_library(lokinet-platform # for networking ev/ev.cpp ev/pipe.cpp - ev/vpnio.cpp ev/ev_libuv.cpp net/ip.cpp + net/ip_address.cpp net/ip_packet.cpp net/ip_range.cpp net/net.cpp net/net_int.cpp + net/sock_addr.cpp $ ) @@ -100,6 +90,11 @@ if(CMAKE_SYSTEM_NAME MATCHES "FreeBSD") endif() add_library(liblokinet + config/config.cpp + config/definition.cpp + config/ini.cpp + config/key_manager.cpp + dns/message.cpp dns/name.cpp dns/question.cpp @@ -109,6 +104,8 @@ add_library(liblokinet consensus/table.cpp + ev/vpnio.cpp + bootstrap.cpp context.cpp crypto/crypto_libsodium.cpp @@ -152,8 +149,6 @@ add_library(liblokinet messages/relay_commit.cpp messages/relay_status.cpp net/address_info.cpp - net/ip_address.cpp - net/sock_addr.cpp net/exit_info.cpp nodedb.cpp path/ihophandler.cpp @@ -200,6 +195,15 @@ add_library(liblokinet service/tag.cpp ) +if(TARGET curl) + # key_manager needs curl for now (to fetch service node keys from lokid) + target_link_libraries(liblokinet PUBLIC curl) + target_compile_definitions(liblokinet PRIVATE HAVE_CURL) + if(TARGET libcurl_external) + add_dependencies(liblokinet libcurl_external) + endif() +endif() + set_target_properties(liblokinet PROPERTIES OUTPUT_NAME lokinet) enable_lto(lokinet-util lokinet-platform liblokinet) diff --git a/llarp/exit/session.hpp b/llarp/exit/session.hpp index 0cddc5579..7eaaf57ca 100644 --- a/llarp/exit/session.hpp +++ b/llarp/exit/session.hpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include diff --git a/llarp/net/ip_packet.hpp b/llarp/net/ip_packet.hpp index 49cf6de02..b11964f19 100644 --- a/llarp/net/ip_packet.hpp +++ b/llarp/net/ip_packet.hpp @@ -86,7 +86,7 @@ struct ipv6_header }; #include -#include +#include #include struct llarp_ev_loop; diff --git a/llarp/service/protocol.hpp b/llarp/service/protocol.hpp index 47e145187..53242234c 100644 --- a/llarp/service/protocol.hpp +++ b/llarp/service/protocol.hpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -31,12 +32,6 @@ namespace llarp { constexpr std::size_t MAX_PROTOCOL_MESSAGE_SIZE = 2048 * 2; - using ProtocolType = uint64_t; - - constexpr ProtocolType eProtocolControl = 0UL; - constexpr ProtocolType eProtocolTrafficV4 = 1UL; - constexpr ProtocolType eProtocolTrafficV6 = 2UL; - /// inner message struct ProtocolMessage { diff --git a/llarp/service/protocol_type.hpp b/llarp/service/protocol_type.hpp new file mode 100644 index 000000000..6ab37db0f --- /dev/null +++ b/llarp/service/protocol_type.hpp @@ -0,0 +1,13 @@ +#pragma once + +#include + +namespace llarp::service { + + using ProtocolType = uint64_t; + + constexpr ProtocolType eProtocolControl = 0UL; + constexpr ProtocolType eProtocolTrafficV4 = 1UL; + constexpr ProtocolType eProtocolTrafficV6 = 2UL; + +}