blob: 7d3c1dd7d073f7aa9e0055445d2211a14de81a54 [file] [log] [blame]
Matt Jeanneret9fba8652019-04-02 12:00:17 -04001#!/bin/sh
2
3set -e
4
5# Copyright 2018 the original author or authors.
6#
7# Licensed under the Apache License, Version 2.0 (the "License");
8# you may not use this file except in compliance with the License.
9# You may obtain a copy of the License at
10#
11# http://www.apache.org/licenses/LICENSE-2.0
12#
13# Unless required by applicable law or agreed to in writing, software
14# distributed under the License is distributed on an "AS IS" BASIS,
15# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16# See the License for the specific language governing permissions and
17# limitations under the License.
18
19export PARENT_DIR="$1"
20export SRC_DIR="${PARENT_DIR}/voltha_protos"
21
22export LD_LIBRARY_PATH=/usr/local/lib
23
24echo $SRC_DIR
25
26export MAPS=Mgoogle/protobuf/descriptor.proto=github.com/golang/protobuf/protoc-gen-go/descriptor
27export INCS="\
28 -I $PARENT_DIR \
29 -I /usr/local/include/googleapis"
30
31export VOLTHA_PB="\
32 $SRC_DIR/adapter.proto \
33 $SRC_DIR/device.proto \
34 $SRC_DIR/events.proto \
35 $SRC_DIR/health.proto \
36 $SRC_DIR/logical_device.proto \
37 $SRC_DIR/ponsim.proto \
38 $SRC_DIR/voltha.proto"
39
40export COMMON_PB="\
41 $SRC_DIR/common.proto \
42 $SRC_DIR/meta.proto \
43 $SRC_DIR/yang_options.proto"
44
45export INTER_CONTAINER_PB="$SRC_DIR/inter_container.proto"
46export SCHEMA_PB="$SRC_DIR/schema.proto"
47export IETF_PB="$SRC_DIR/ietf_interfaces.proto"
48export OF_PB="$SRC_DIR/openflow_13.proto"
49export OMCI_PB="$SRC_DIR/omci*.proto"
50export AFROUTER_PB="$SRC_DIR/afrouter.proto"
51
52export PB_VARS="\
53 VOLTHA_PB \
54 COMMON_PB \
55 INTER_CONTAINER_PB \
56 SCHEMA_PB \
57 IETF_PB \
58 OF_PB \
59 OMCI_PB \
60 AFROUTER_PB \
61 OMCI_PB"
62
63export OTHER_INCLUDES="/usr/local/include/googleapis"
64export PROTO_DESC_FILE="go/voltha.pb"
65
66for pb_var in $PB_VARS
67do
68 pbs="$(eval echo \$$pb_var)"
69 echo "Compiling $pbs"
70 protoc --go_out=$MAPS,plugins=grpc:$GOPATH/src $INCS $pbs
71done
72
73protoc -I ${PARENT_DIR} -I ${OTHER_INCLUDES} --include_imports --include_source_info --descriptor_set_out=${PROTO_DESC_FILE} ${SRC_DIR}/*.proto