summaryrefslogtreecommitdiffhomepage
path: root/tools
diff options
context:
space:
mode:
authorSatoshi Fujimoto <satoshi.fujimoto7@gmail.com>2017-06-29 14:50:05 +0900
committerSatoshi Fujimoto <satoshi.fujimoto7@gmail.com>2017-06-30 13:32:57 +0900
commitaea13caea6ffc5a373fbfd5157c57d026b9f9a7a (patch)
treef0f3eeb4798001e319e192ed5a21ed61a52c20fd /tools
parente314f126c1c5dc81c0d8ab33a4b450a10674052c (diff)
grpc: Improve building tools and docs for C++ client
This patch includes the following fixes: * update Makefile for protobuf 3.3.0 / gRPC 1.4.1 * make build.sh which generates stub codes and builds GoBGP shared library (instead, remove those operations from docs) Signed-off-by: Satoshi Fujimoto <satoshi.fujimoto7@gmail.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/grpc/cpp/Makefile16
-rw-r--r--tools/grpc/cpp/build.sh11
2 files changed, 24 insertions, 3 deletions
diff --git a/tools/grpc/cpp/Makefile b/tools/grpc/cpp/Makefile
index 2fcb5c8c..d50df9d9 100644
--- a/tools/grpc/cpp/Makefile
+++ b/tools/grpc/cpp/Makefile
@@ -1,7 +1,17 @@
+HOST_SYSTEM = $(shell uname | cut -f 1 -d_)
+SYSTEM ?= $(HOST_SYSTEM)
CXX = g++
-CPPFLAGS += -I/opt/protobuf_3.0.0_alpha4/include -I/opt/grpc/include -pthread
+CPPFLAGS += -I/usr/local/include -pthread
CXXFLAGS += -std=c++11
-LDFLAGS += -L/opt/grpc/lib -L/opt/protobuf_3.0.0_alpha4/lib -lgrpc++_unsecure -lgrpc -lgpr -lprotobuf -lpthread -ldl
+ifeq ($(SYSTEM),Darwin)
+LDFLAGS += -L/usr/local/lib `pkg-config --libs grpc++` \
+ -lgrpc++_reflection \
+ -lprotobuf -lpthread -ldl
+else
+LDFLAGS += -L/usr/local/lib `pkg-config --libs grpc++` \
+ -Wl,--no-as-needed -lgrpc++_reflection -Wl,--as-needed \
+ -lprotobuf -lpthread -ldl
+endif
PROTOC = protoc
GRPC_CPP_PLUGIN = grpc_cpp_plugin
GRPC_CPP_PLUGIN_PATH ?= `which $(GRPC_CPP_PLUGIN)`
@@ -13,7 +23,7 @@ vpath %.proto $(PROTOS_PATH)
all: system-check gobgp_api_client
gobgp_api_client: gobgp_api_client.pb.o gobgp_api_client.grpc.pb.o gobgp_api_client.o
- $(CXX) $^ $(LDFLAGS) -L. -lgobgp -o $@
+ $(CXX) $^ $(LDFLAGS) -L. -lgobgp -o $@
%.grpc.pb.cc: %.proto
$(PROTOC) -I $(PROTOS_PATH) --grpc_out=. --plugin=protoc-gen-grpc=$(GRPC_CPP_PLUGIN_PATH) $<
diff --git a/tools/grpc/cpp/build.sh b/tools/grpc/cpp/build.sh
new file mode 100644
index 00000000..f1c7a92c
--- /dev/null
+++ b/tools/grpc/cpp/build.sh
@@ -0,0 +1,11 @@
+#!/bin/bash
+
+GOBGP_PATH=${GOPATH}/src/github.com/osrg/gobgp
+
+cd ${GOBGP_PATH}/gobgp/lib
+go build -buildmode=c-shared -o libgobgp.so *.go
+cd ${GOBGP_PATH}/tools/grpc/cpp
+ln -s ${GOBGP_PATH}/gobgp/lib/libgobgp.h
+ln -s ${GOBGP_PATH}/gobgp/lib/libgobgp.so
+ln -s ${GOBGP_PATH}/api/gobgp.proto gobgp_api_client.proto
+make