Page MenuHomePhabricator

D3867.id14910.diff
No OneTemporary

D3867.id14910.diff

diff --git a/native/cpp/CommonCpp/grpc/CMakeLists.txt b/native/cpp/CommonCpp/grpc/CMakeLists.txt
new file mode 100644
--- /dev/null
+++ b/native/cpp/CommonCpp/grpc/CMakeLists.txt
@@ -0,0 +1,106 @@
+project(grpc-comm)
+cmake_minimum_required(VERSION 3.4)
+
+include(GNUInstallDirs)
+find_package(protobuf REQUIRED)
+find_package(gRPC REQUIRED)
+
+set(_components backup blob tunnelbroker)
+set(TARGETS)
+# Iterate through each protobuf file
+# and create headers, sources, and export as component library
+foreach(_component ${_components})
+ set(LIB_NAME comm-${_component}-grpc)
+ set(TARGETS ${TARGETS} ${LIB_NAME})
+
+ set(PROTO_HDRS
+ ${CMAKE_CURRENT_SOURCE_DIR}/_generated/${_component}.pb.h
+ ${CMAKE_CURRENT_SOURCE_DIR}/_generated/${_component}.grpc.pb.h
+ )
+
+ set(PROTO_SRCS
+ ${CMAKE_CURRENT_SOURCE_DIR}/_generated/${_component}.pb.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/_generated/${_component}.grpc.pb.cc
+ )
+
+ add_library(${LIB_NAME}
+ ${PROTO_HDRS} ${PROTO_SRCS}
+ )
+
+ target_link_libraries(${LIB_NAME}
+ gRPC::grpc++
+ protobuf::libprotobuf
+ )
+
+ # reference local directory when building
+ # use installation path when installing
+ target_include_directories(${LIB_NAME}
+ PUBLIC
+ $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/_generated>
+ $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../Tools>
+ $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
+ )
+
+ install(TARGETS ${LIB_NAME} EXPORT comm-export
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT ${LIB_NAME}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT ${LIB_NAME}
+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT ${LIB_NAME}
+ )
+
+ # ensure headers are also installed
+ install(FILES ${PROTO_HDRS} DESTINATION include/comm/grpc)
+endforeach()
+
+set(CLIENT_HDRS
+ "Client.h"
+ "ClientGetReadReactor.h"
+ "GRPCStreamHostObject.h"
+)
+
+set(CLIENT_SRCS
+ "Client.cpp"
+ "ClientGetReadReactor.cpp"
+ "GRPCStreamHostObject.cpp"
+)
+
+add_library(comm-client
+ ${CLIENT_HDRS}
+ ${CLIENT_SRCS}
+)
+
+target_link_libraries(comm-client
+ gRPC::grpc++
+ protobuf::libprotobuf
+ comm-tunnelbroker-grpc
+)
+
+target_include_directories(comm-client
+ PUBLIC
+ $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/..>
+ $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
+ # HACK: add complete cmake support to react-native?
+ PRIVATE
+ "../../../node_modules/react-native/ReactCommon/callinvoker"
+ "../../../node_modules/react-native/ReactCommon/jsi"
+)
+
+install(TARGETS comm-client EXPORT comm-export
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT comm-client
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT comm-client
+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT comm-client
+)
+
+install(FILES ${CLIENT_HDRS} DESTINATION include/grpc)
+
+# For development purposes, able to reference build directory
+export(TARGETS ${TARGETS} comm-client
+ NAMESPACE comm-grpc::
+ FILE ${CMAKE_CURRENT_BINARY_DIR}/cmake/comm-grpc/comm-grpc-targets.cmake
+)
+
+# For installation
+install(EXPORT comm-export
+ FILE comm-grpc-targets.cmake
+ DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/comm-grpc
+ NAMESPACE comm-grpc::
+)
diff --git a/nix/overlay.nix b/nix/overlay.nix
--- a/nix/overlay.nix
+++ b/nix/overlay.nix
@@ -29,6 +29,8 @@
protobuf_3_15_cmake = prev.callPackage ./protobuf_3_15.nix { };
+ comm-grpc = final.callPackage ./comm-grpc.nix { };
+
devShell = final.callPackage ./dev-shell.nix { };
mysql-down = prev.callPackage ./mysql-down-linux.nix { };

File Metadata

Mime Type
text/plain
Expires
Sun, Nov 17, 5:17 AM (17 h, 49 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2514445
Default Alt Text
D3867.id14910.diff (3 KB)

Event Timeline