[VOL-1460]
- Imported protobuf definitions from pyvoltha at
https://gerrit.opencord.org/gitweb?p=pyvoltha.git, commit hash:
944aee71301b8ddb211b6e51d685f56d5c4a911b
- Imported upstream Google API protos from
https://github.com/googleapis/googleapis, commit hash:
5a90fbea68ce4a6e87c20d2df10df5ecd88299ff
- Fixed `import` paths and directory heirarchy in protobuf definitions
to be compatible with both python 2 and 3.
- Created Makefile scaffold to generate language-specific bindings for
python and go
Change-Id: Idd6b6b985a5eae4c38d40dd07ae78744c09e37f5
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..681b61f
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,79 @@
+# Copyright 2019-present Open Networking Foundation
+#
+# 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.
+
+# Makefile for voltha-protos
+default: test
+
+# Variables
+PROTO_FILES := $(wildcard protos/voltha_protos/*.proto)
+PROTO_PYTHON_DEST_DIR := python/voltha_protos
+PROTO_PYTHON_PB2 := $(foreach f, $(PROTO_FILES), $(patsubst protos/voltha_protos/%.proto,$(PROTO_PYTHON_DEST_DIR)/%_pb2.py,$(f)))
+
+print:
+ echo "Proto files: $(PROTO_FILES)"
+ echo "Python PB2 files: $(PROTO_PYTHON_PB2)"
+
+# set default shell
+SHELL = bash -e -o pipefail
+
+# Generic targets
+protos: python-protos go-protos
+
+build: python-build go-build
+
+test: python-test go-test
+
+clean: python-clean go-clean
+
+# Python targets
+python-protos: $(PROTO_PYTHON_PB2)
+
+venv_protos:
+ virtualenv $@;\
+ source ./$@/bin/activate ; set -u ;\
+ pip install grpcio-tools googleapis-common-protos
+
+$(PROTO_PYTHON_DEST_DIR)/%_pb2.py: protos/voltha_protos/%.proto Makefile venv_protos
+ source ./venv_protos/bin/activate ; set -u ;\
+ python -m grpc_tools.protoc \
+ -I protos \
+ --python_out=python \
+ --grpc_python_out=python \
+ --descriptor_set_out=$(PROTO_PYTHON_DEST_DIR)/$(basename $(notdir $<)).desc \
+ --include_imports \
+ --include_source_info \
+ $<
+
+python-build: setup.py
+ python ./setup.py sdist
+
+python-test: tox.ini setup.py python-protos
+ tox
+
+python-clean:
+ rm -rf venv_protos .coverage coverage.xml nose2-results.xml dist $(PROTO_PYTHON_PB2) $(PROTO_PYTHON_DEST_DIR)*.desc
+
+# Go targets
+go-protos:
+ echo "FIXME: Add golang protos"
+
+go-build:
+ echo "FIXME: Add golang build"
+
+go-test:
+ echo "FIXME: Add golang tests"
+
+go-clean:
+ echo "FIXME: Add golang cleanup"
+