summaryrefslogtreecommitdiffhomepage
path: root/tools
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@gmail.com>2019-04-06 21:48:21 +0900
committerFUJITA Tomonori <fujita.tomonori@gmail.com>2019-04-06 21:48:21 +0900
commit2965e8092e4510c35d13304f2896ce5d7593d635 (patch)
tree337100942a3fc0d2b772ab01bb331014181a1d82 /tools
parentd39243ad363293c78af93af401c40649fe97610c (diff)
add script to generate api/gobgp.pb.go
Signed-off-by: FUJITA Tomonori <fujita.tomonori@gmail.com>
Diffstat (limited to 'tools')
-rwxr-xr-xtools/grpc/genproto.sh34
-rw-r--r--tools/tools.go22
2 files changed, 56 insertions, 0 deletions
diff --git a/tools/grpc/genproto.sh b/tools/grpc/genproto.sh
new file mode 100755
index 00000000..28b3497e
--- /dev/null
+++ b/tools/grpc/genproto.sh
@@ -0,0 +1,34 @@
+#!/usr/bin/env bash -x
+# stolen from prometheus
+#
+# Generate all protobuf bindings.
+# Run from repository root.
+
+set -e
+set -u
+
+if ! [[ "$0" =~ "tools/grpc/genproto.sh" ]]; then
+ echo "must be run from repository root"
+ exit 255
+fi
+
+if ! [[ $(protoc --version) =~ "3.7.1" ]]; then
+ echo "could not find protoc 3.7.1, is it installed + in PATH?"
+ exit 255
+fi
+
+echo "installing plugins"
+GO111MODULE=on go mod download
+
+INSTALL_PKGS="github.com/golang/protobuf/protoc-gen-go"
+for pkg in ${INSTALL_PKGS}; do
+ GO111MODULE=on go install "$pkg"
+done
+
+GOBGP="${PWD}"
+GOPROTO="$(GO111MODULE=on go list -f '{{ .Dir }}' -m github.com/golang/protobuf)"
+
+echo "generating code"
+protoc -I "${GOPROTO}"/ptypes \
+ -I "${GOBGP}"/api \
+ --go_out=plugins=grpc:${GOBGP}/api "${GOBGP}"/api/*.proto
diff --git a/tools/tools.go b/tools/tools.go
new file mode 100644
index 00000000..2929aa67
--- /dev/null
+++ b/tools/tools.go
@@ -0,0 +1,22 @@
+// Copyright (C) 2019 Nippon Telegraph and Telephone Corporation.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+// implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+// +build tools
+
+package tools
+
+import (
+ _ "github.com/golang/protobuf/protoc-gen-go"
+)