commit | 61e94873aa4b4cfd5e9277c666402214b031c05b | [log] [tgz] |
---|---|---|
author | Matt Jeanneret <mj3580@att.com> | Fri Mar 22 16:16:01 2019 -0400 |
committer | Matt Jeanneret <mj3580@att.com> | Thu Mar 28 11:05:29 2019 -0500 |
tree | d601b52e5a07fa06c74c6a2134f394c6f3c52654 | |
parent | 7c15159ef0650e3682e24e437dbcf8128ede5c45 [diff] |
VOL-1460 Generate stubs from proper version of protoc-gen-go The go get for protobuf installs the :master verson of protoc-gen-go. After the checkout of 1.3.1 run make install (go install) again so the correct protoc-gen-go binary is generated. Also fix typo in makefile that prevented install-protoc Change-Id: I1cf5da45ef6cee998d8b4658a941518d3be94369
Protobuf files used by VOLTHA.
Currently this is used to generate both Golang and Python protobufs and gRPC stubs.
Protobuf definition files are located in protos/voltha_protos
directory. This directory hierarchy and import scheme is required to allow the python code generated by the gRPC compiler to have the correct import paths.
NOTE: The
protos/google/api
directory has files copied from the Google APIs, and is only included for initial compilation of the VOLTHA protobuf files - these API's should be installed independently via either the python googleapis-common-protos package or the golang go-genproto repo.
Get the voltha-protos repository:
mkdir -p ~/source cd ~/source git clone https://gerrit.opencord.org/voltha-protos cd voltha-protos
After installing Go on a Mac or Linux environment, the GOPATH environment variable needs be set. These instructions assume its ~/go. Create a symbolic link in the $GOPATH/src tree to the voltha-go repository:
mkdir -p $GOPATH/src/github.com/opencord ln -s ~/source/voltha-protos $GOPATH/src/github.com/opencord/voltha-protos
Checkout and go install correct version of protoc-gen-go. make install build and runs go install
cd $GOPATH/src/github.com/opencord/voltha-protos go get -d github.com/golang/protobuf/ cd $GOPATH/src/github.com/golang/protobuf git checkout v1.3.1 make install
Install libprotoc 3.7.0 manually or use the Makefile target install it. Then build the python and golang stubs
cd $GOPATH/src/github.com/opencord/voltha-protos make install-protoc make build
use dist/*.tar.gz for local python imports use go/ for local go imports
Installation from Pypi:
pip install voltha-protos
or from a local build:
pip install ~/source/voltha-protos/dist/*.tar.gz
To use it within your code (for example)
from voltha_protos import voltha_pb2
go get github.com/opencord/voltha-protos cd $GOPATH/github.com/opencord/voltha-protos make build
protos should be importable from github.com/opencord/voltha-protos/go/packagename
To use the libraries, import protos with the root path github.com/opencord/voltha-protos/go/
make test
will run tests for all languages.