Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3354397
D3236.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
4 KB
Referenced Files
None
Subscribers
None
D3236.diff
View Options
diff --git a/services/tunnelbroker/CMakeLists.txt b/services/tunnelbroker/CMakeLists.txt
--- a/services/tunnelbroker/CMakeLists.txt
+++ b/services/tunnelbroker/CMakeLists.txt
@@ -16,6 +16,7 @@
message(STATUS "Using protobuf ${Protobuf_VERSION}")
set(_PROTOBUF_LIBPROTOBUF protobuf::libprotobuf)
+set(_REFLECTION gRPC::grpc++_reflection)
set(_PROTOBUF_PROTOC $<TARGET_FILE:protobuf::protoc>)
# gRPC building parameters
@@ -59,8 +60,31 @@
add_subdirectory(./lib/glog)
+# Generated sources
+get_filename_component(proto "protos/tunnelbroker.proto" ABSOLUTE)
+get_filename_component(proto_path "${proto}" PATH)
+
+set(GENERATED_BASE_DIR "${CMAKE_CURRENT_BINARY_DIR}/gen")
+set(GENERATED_CODE_DIR "${GENERATED_BASE_DIR}/_generated")
+file(MAKE_DIRECTORY ${GENERATED_CODE_DIR})
+
+set(proto_srcs "${GENERATED_CODE_DIR}/tunnelbroker.pb.cc")
+set(proto_hdrs "${GENERATED_CODE_DIR}/tunnelbroker.pb.h")
+set(grpc_srcs "${GENERATED_CODE_DIR}/tunnelbroker.grpc.pb.cc")
+set(grpc_hdrs "${GENERATED_CODE_DIR}/tunnelbroker.grpc.pb.h")
+add_custom_command(
+ OUTPUT "${proto_srcs}" "${proto_hdrs}" "${grpc_srcs}" "${grpc_hdrs}"
+ COMMAND ${_PROTOBUF_PROTOC}
+ ARGS --grpc_out "${GENERATED_CODE_DIR}"
+ --cpp_out "${GENERATED_CODE_DIR}"
+ -I "${proto_path}"
+ --plugin=protoc-gen-grpc="${_GRPC_CPP_PLUGIN_EXECUTABLE}"
+ "${proto}"
+ DEPENDS "${proto}"
+)
+
file(GLOB SOURCE_CODE "./src/*.cpp" "./src/**/*.cpp")
-file(GLOB GENERATED_CODE "./_generated/*.cc")
+set(GENERATED_CODE ${proto_srcs} ${proto_hdrs} ${grpc_srcs} ${grpc_hdrs})
file(GLOB DOUBLE_CONVERSION_SOURCES "./lib/double-conversion/double-conversion/*.cc")
add_definitions(
@@ -78,7 +102,7 @@
./src/Service
./src/Tools
./src/Amqp
- ./_generated
+ ${GENERATED_BASE_DIR}
./lib/folly
./lib/double-conversion
${Boost_INCLUDE_DIR}
@@ -89,7 +113,7 @@
set(
SOURCE_CODE
-
+
# folly
./lib/folly/folly/detail/Futex.cpp
./lib/folly/folly/synchronization/ParkingLot.cpp
@@ -138,7 +162,7 @@
${_GRPC_GRPCPP}
${_PROTOBUF_LIBPROTOBUF}
- gRPC::grpc++_reflection
+ ${_REFLECTION}
${AWSSDK_LINK_LIBRARIES}
${AMQPCPP_LIBRARIES}
${CRYPTOPP_LIBRARIES}
@@ -184,7 +208,7 @@
)
target_link_libraries(
runTests
-
+
${LIBS}
gtest
gtest_main
diff --git a/services/tunnelbroker/Dockerfile b/services/tunnelbroker/Dockerfile
--- a/services/tunnelbroker/Dockerfile
+++ b/services/tunnelbroker/Dockerfile
@@ -8,6 +8,9 @@
zlib1g-dev \
&& rm -rf /var/lib/apt/lists/*
+ARG MAKE_JOBS=4
+ENV MAKEFLAGS="-j${MAKE_JOBS}"
+
RUN mkdir /transferred/scripts
WORKDIR /transferred/scripts
diff --git a/services/tunnelbroker/build.sh b/services/tunnelbroker/build.sh
deleted file mode 100755
--- a/services/tunnelbroker/build.sh
+++ /dev/null
@@ -1,21 +0,0 @@
-#!/bin/bash
-
-set -e
-
-NPROC=0
-
-NPROC=$(nproc 2> /dev/null || echo 1)
-if [[ $NPROC -eq 1 ]]
-then
- NPROC=$(sysctl -n hw.physicalcpu 2> /dev/null || echo 1)
-fi
-
-echo "building the server (nproc=$NPROC)..."
-
-pushd cmake/build
-cmake ../..
-make -j $NPROC
-
-popd
-
-echo "success - server built"
diff --git a/services/tunnelbroker/docker/build_server.sh b/services/tunnelbroker/docker/build_server.sh
--- a/services/tunnelbroker/docker/build_server.sh
+++ b/services/tunnelbroker/docker/build_server.sh
@@ -13,11 +13,11 @@
ln -s /usr/lib/double-conversion
popd # lib
-rm -rf _generated
-mkdir _generated
-
rm -rf cmake/build
mkdir -p cmake/build
-./generate.sh
-./build.sh
+echo "building the server (MAKEFLAGS=$MAKEFLAGS)..."
+pushd cmake/build
+cmake ../..
+make
+popd # cmake/build
diff --git a/services/tunnelbroker/generate.sh b/services/tunnelbroker/generate.sh
deleted file mode 100755
--- a/services/tunnelbroker/generate.sh
+++ /dev/null
@@ -1,9 +0,0 @@
-#!/bin/bash
-
-set -e
-
-echo "generating files from protos..."
-
-protoc -I=./protos --cpp_out=_generated --grpc_out=_generated --plugin=protoc-gen-grpc=`which grpc_cpp_plugin` ./protos/tunnelbroker.proto
-
-echo "success - code generated from protos"
diff --git a/services/tunnelbroker/src/Service/TunnelbrokerServiceImpl.h b/services/tunnelbroker/src/Service/TunnelbrokerServiceImpl.h
--- a/services/tunnelbroker/src/Service/TunnelbrokerServiceImpl.h
+++ b/services/tunnelbroker/src/Service/TunnelbrokerServiceImpl.h
@@ -1,7 +1,7 @@
#pragma once
-#include "../_generated/tunnelbroker.grpc.pb.h"
-#include "../_generated/tunnelbroker.pb.h"
+#include <_generated/tunnelbroker.grpc.pb.h>
+#include <_generated/tunnelbroker.pb.h>
#include <grpcpp/grpcpp.h>
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Nov 24, 12:51 PM (21 h, 21 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2575683
Default Alt Text
D3236.diff (4 KB)
Attached To
Mode
D3236: tunnelbroker: Generate gRPC/protobuf code with CMake
Attached
Detach File
Event Timeline
Log In to Comment