From 68c4c67030a983bb731df9d52593fef5d94885e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bylica?= Date: Wed, 6 Dec 2017 13:00:40 +0100 Subject: [PATCH 1/2] deps: Use libjson-rpc-cpp from Hunter This replaces our own ExternalProject of libjson-rpc-cpp --- CMakeLists.txt | 4 +- circle.yml | 2 +- cmake/Hunter/config.cmake | 16 ++++++- cmake/ProjectJsonRpcCpp.cmake | 84 ----------------------------------- libweb3jsonrpc/CMakeLists.txt | 2 +- 5 files changed, 20 insertions(+), 88 deletions(-) delete mode 100644 cmake/ProjectJsonRpcCpp.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 80b3fb0636e..2c95e07e7ea 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -110,7 +110,9 @@ find_package(Snappy CONFIG REQUIRED) hunter_add_package(cryptopp) find_package(cryptopp CONFIG REQUIRED) -include(ProjectJsonRpcCpp) +hunter_add_package(libjson-rpc-cpp) +find_package(libjson-rpc-cpp CONFIG REQUIRED) + include(ProjectSecp256k1) include(ProjectLibFF) diff --git a/circle.yml b/circle.yml index 8073ee3c3f2..3e030672021 100644 --- a/circle.yml +++ b/circle.yml @@ -67,7 +67,7 @@ defaults: save-deps-cache: &save-deps-cache cache-save: name: "Save dependencies cache" - key: &deps-cache-key deps-2-{{arch}}-{{checksum "compiler.version"}}-{{checksum "cmake/ProjectJsonRpcCpp.cmake"}} + key: &deps-cache-key deps-2-{{arch}}-{{checksum "compiler.version"}}-{{checksum "cmake/LibFF.cmake"}} paths: - build/deps diff --git a/cmake/Hunter/config.cmake b/cmake/Hunter/config.cmake index e3f0b7de4a7..3f1bf893f62 100644 --- a/cmake/Hunter/config.cmake +++ b/cmake/Hunter/config.cmake @@ -1,4 +1,18 @@ # cryptopp has very bad CMakeLists.txt config. # We have to enforce "cross compiling mode" there by setting CMAKE_SYSTEM_VERSION=NO # to any "false" value. -hunter_config(cryptopp VERSION ${HUNTER_cryptopp_VERSION} CMAKE_ARGS CMAKE_SYSTEM_VERSION=NO) \ No newline at end of file +hunter_config(cryptopp VERSION ${HUNTER_cryptopp_VERSION} CMAKE_ARGS CMAKE_SYSTEM_VERSION=NO) + +hunter_config( + libjson-rpc-cpp + VERSION ${HUNTER_libjson-rpc-cpp_VERSION} + CMAKE_ARGS + UNIX_DOMAIN_SOCKET_SERVER=YES + UNIX_DOMAIN_SOCKET_CLIENT=NO + FILE_DESCRIPTOR_SERVER=NO + FILE_DESCRIPTOR_CLIENT=NO + TCP_SOCKET_SERVER=NO + TCP_SOCKET_CLIENT=NO + HTTP_SERVER=NO + HTTP_CLIENT=NO +) \ No newline at end of file diff --git a/cmake/ProjectJsonRpcCpp.cmake b/cmake/ProjectJsonRpcCpp.cmake deleted file mode 100644 index a4818fa0487..00000000000 --- a/cmake/ProjectJsonRpcCpp.cmake +++ /dev/null @@ -1,84 +0,0 @@ -include(ExternalProject) - -get_property(jsoncpp_include_dir TARGET jsoncpp_lib_static PROPERTY INTERFACE_INCLUDE_DIRECTORIES) -get_property(jsoncpp_library TARGET jsoncpp_lib_static PROPERTY IMPORTED_LOCATION_RELEASE) - -set(prefix "${CMAKE_BINARY_DIR}/deps") -if (WIN32) - # On Windows CMAKE_INSTALL_PREFIX is ignored and installs to dist dir. - set(INSTALL_DIR ${prefix}/src/jsonrpccpp-build/dist) -else() - set(INSTALL_DIR ${prefix}) -endif() -set(JSONRPCCPP_INCLUDE_DIR ${INSTALL_DIR}/include) -set(JSONRPCCPP_COMMON_LIBRARY ${INSTALL_DIR}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}jsonrpccpp-common${CMAKE_STATIC_LIBRARY_SUFFIX}) -set(JSONRPCCPP_SERVER_LIBRARY ${INSTALL_DIR}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}jsonrpccpp-server${CMAKE_STATIC_LIBRARY_SUFFIX}) - -set(CMAKE_ARGS -DCMAKE_INSTALL_PREFIX= - -DCMAKE_BUILD_TYPE=Release - -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} - -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} - # Build static lib but suitable to be included in a shared lib. - -DCMAKE_POSITION_INDEPENDENT_CODE=${BUILD_SHARED_LIBS} - -DBUILD_STATIC_LIBS=On - -DBUILD_SHARED_LIBS=Off - -DUNIX_DOMAIN_SOCKET_SERVER=Off - -DUNIX_DOMAIN_SOCKET_CLIENT=Off - -DHTTP_SERVER=OFF - -DHTTP_CLIENT=OFF - -DCOMPILE_TESTS=Off - -DCOMPILE_STUBGEN=Off - -DCOMPILE_EXAMPLES=Off - # Point to jsoncpp library. - -DJSONCPP_INCLUDE_DIR=${jsoncpp_include_dir} - # Select jsoncpp include prefix: or - -DJSONCPP_INCLUDE_PREFIX=json - -DJSONCPP_LIBRARY=${jsoncpp_library} - -DMHD_INCLUDE_DIR=${MHD_INCLUDE_DIR} - -DMHD_LIBRARY=${MHD_LIBRARY}) - -if (WIN32) - # For Windows we have to provide also locations for debug libraries. - set(CMAKE_ARGS ${CMAKE_ARGS} - -DJSONCPP_LIBRARY_DEBUG=${jsoncpp_library} - -DMHD_LIBRARY_DEBUG=${MHD_LIBRARY}) -endif() - -ExternalProject_Add( - jsonrpccpp - PREFIX "${prefix}" - DOWNLOAD_NAME jsonrcpcpp-0.7.0.tar.gz - DOWNLOAD_NO_PROGRESS 1 - URL https://github.com/cinemast/libjson-rpc-cpp/archive/v0.7.0.tar.gz - URL_HASH SHA256=669c2259909f11a8c196923a910f9a16a8225ecc14e6c30e2bcb712bab9097eb - # On Windows it tries to install this dir. Create it to prevent failure. - PATCH_COMMAND ${CMAKE_COMMAND} -E make_directory /win32-deps/include - CMAKE_ARGS ${CMAKE_ARGS} - LOG_CONFIGURE 1 - # Overwrite build and install commands to force Release build on MSVC. - BUILD_COMMAND ${CMAKE_COMMAND} --build --config Release - INSTALL_COMMAND ${CMAKE_COMMAND} --build --config Release --target install - LOG_INSTALL 1 - BUILD_BYPRODUCTS "${JSONRPCCPP_COMMON_LIBRARY}" "${JSONRPCCPP_SERVER_LIBRARY}" -) - -# Create imported libraries -file(MAKE_DIRECTORY ${JSONRPCCPP_INCLUDE_DIR}) # Must exist. - -add_library(JsonRpcCpp::Common STATIC IMPORTED) -set_property(TARGET JsonRpcCpp::Common PROPERTY IMPORTED_CONFIGURATIONS Release) -set_property(TARGET JsonRpcCpp::Common PROPERTY IMPORTED_LOCATION_RELEASE ${JSONRPCCPP_COMMON_LIBRARY}) -set_property(TARGET JsonRpcCpp::Common PROPERTY INTERFACE_LINK_LIBRARIES jsoncpp_lib_static) -set_property(TARGET JsonRpcCpp::Common PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${JSONRPCCPP_INCLUDE_DIR} ${jsoncpp_include_dir}) -add_dependencies(JsonRpcCpp::Common jsonrpccpp) - -add_library(JsonRpcCpp::Server STATIC IMPORTED) -set_property(TARGET JsonRpcCpp::Server PROPERTY IMPORTED_CONFIGURATIONS Release) -set_property(TARGET JsonRpcCpp::Server PROPERTY IMPORTED_LOCATION_RELEASE ${JSONRPCCPP_SERVER_LIBRARY}) -set_property(TARGET JsonRpcCpp::Server PROPERTY INTERFACE_LINK_LIBRARIES JsonRpcCpp::Common ${MHD_LIBRARY}) -set_property(TARGET JsonRpcCpp::Server PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${MHD_INCLUDE_DIR}) -add_dependencies(JsonRpcCpp::Server jsonrpccpp) - -unset(BINARY_DIR) -unset(INSTALL_DIR) -unset(CMAKE_ARGS) diff --git a/libweb3jsonrpc/CMakeLists.txt b/libweb3jsonrpc/CMakeLists.txt index 827769e52c8..b46074c29e3 100644 --- a/libweb3jsonrpc/CMakeLists.txt +++ b/libweb3jsonrpc/CMakeLists.txt @@ -43,4 +43,4 @@ jsonrpcstub_create(web3jsonrpc test.json TestClient ${CMAKE_CURRENT_BINARY_DIR} TestClient ) -target_link_libraries(web3jsonrpc ethashseal webthree JsonRpcCpp::Server) +target_link_libraries(web3jsonrpc ethashseal webthree libjson-rpc-cpp::server) From a323f2f8ef55883d09ecba67189bf3b3e187ed7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bylica?= Date: Wed, 6 Dec 2017 14:52:17 +0100 Subject: [PATCH 2/2] rpc: Use UnixSocketServer from libjson-rpc-cpp --- eth/main.cpp | 9 ++++++++- libweb3jsonrpc/IpcServer.h | 14 ++++++-------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/eth/main.cpp b/eth/main.cpp index 520022475ea..aa81242a943 100644 --- a/eth/main.cpp +++ b/eth/main.cpp @@ -1152,9 +1152,16 @@ int main(int argc, char** argv) new rpc::Debug(*web3.ethereum()), testEth )); - auto ipcConnector = new IpcServer("geth"); + + fs::path ipcPath = getIpcPath(); + if (ipcPath.empty()) + ipcPath = getDataDir(); + ipcPath /= "geth.ipc"; + + auto ipcConnector = new IpcServer(ipcPath.string()); jsonrpcIpcServer->addConnector(ipcConnector); ipcConnector->StartListening(); + cnote << "IPC path: " << ipcPath; if (jsonAdmin.empty()) diff --git a/libweb3jsonrpc/IpcServer.h b/libweb3jsonrpc/IpcServer.h index 33400def760..6845955f99b 100644 --- a/libweb3jsonrpc/IpcServer.h +++ b/libweb3jsonrpc/IpcServer.h @@ -14,21 +14,19 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with cpp-ethereum. If not, see . */ -/** @file IpcServer.h -* @authors: -* Arkadiy Paronyan -* @date 2015 -*/ #pragma once -#include "UnixSocketServer.h" +#if _WIN32 #include "WinPipeServer.h" +#else +#include +#endif namespace dev { #if defined(_WIN32) - using IpcServer = WindowsPipeServer; +using IpcServer = WindowsPipeServer; #else - using IpcServer = UnixDomainSocketServer; +using IpcServer = jsonrpc::UnixDomainSocketServer; #endif } // namespace dev