Zack Williams | 5220966 | 2019-02-07 10:15:31 -0700 | [diff] [blame] | 1 | # Copyright 2019-present Open Networking Foundation |
| 2 | # |
| 3 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | # you may not use this file except in compliance with the License. |
| 5 | # You may obtain a copy of the License at |
| 6 | # |
| 7 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | # |
| 9 | # Unless required by applicable law or agreed to in writing, software |
| 10 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | # See the License for the specific language governing permissions and |
| 13 | # limitations under the License. |
| 14 | |
| 15 | # Makefile for voltha-protos |
| 16 | default: test |
| 17 | |
| 18 | # Variables |
| 19 | PROTO_FILES := $(wildcard protos/voltha_protos/*.proto) |
| 20 | PROTO_PYTHON_DEST_DIR := python/voltha_protos |
| 21 | PROTO_PYTHON_PB2 := $(foreach f, $(PROTO_FILES), $(patsubst protos/voltha_protos/%.proto,$(PROTO_PYTHON_DEST_DIR)/%_pb2.py,$(f))) |
| 22 | |
| 23 | print: |
| 24 | echo "Proto files: $(PROTO_FILES)" |
| 25 | echo "Python PB2 files: $(PROTO_PYTHON_PB2)" |
| 26 | |
| 27 | # set default shell |
| 28 | SHELL = bash -e -o pipefail |
| 29 | |
| 30 | # Generic targets |
| 31 | protos: python-protos go-protos |
| 32 | |
William Kurkian | f262e63 | 2019-03-04 17:04:30 -0500 | [diff] [blame^] | 33 | build: protos python-build go-build |
Zack Williams | 5220966 | 2019-02-07 10:15:31 -0700 | [diff] [blame] | 34 | |
| 35 | test: python-test go-test |
| 36 | |
| 37 | clean: python-clean go-clean |
| 38 | |
| 39 | # Python targets |
| 40 | python-protos: $(PROTO_PYTHON_PB2) |
| 41 | |
| 42 | venv_protos: |
| 43 | virtualenv $@;\ |
| 44 | source ./$@/bin/activate ; set -u ;\ |
| 45 | pip install grpcio-tools googleapis-common-protos |
| 46 | |
| 47 | $(PROTO_PYTHON_DEST_DIR)/%_pb2.py: protos/voltha_protos/%.proto Makefile venv_protos |
| 48 | source ./venv_protos/bin/activate ; set -u ;\ |
| 49 | python -m grpc_tools.protoc \ |
| 50 | -I protos \ |
| 51 | --python_out=python \ |
| 52 | --grpc_python_out=python \ |
| 53 | --descriptor_set_out=$(PROTO_PYTHON_DEST_DIR)/$(basename $(notdir $<)).desc \ |
| 54 | --include_imports \ |
| 55 | --include_source_info \ |
| 56 | $< |
| 57 | |
| 58 | python-build: setup.py |
| 59 | python ./setup.py sdist |
| 60 | |
| 61 | python-test: tox.ini setup.py python-protos |
| 62 | tox |
| 63 | |
| 64 | python-clean: |
| 65 | rm -rf venv_protos .coverage coverage.xml nose2-results.xml dist $(PROTO_PYTHON_PB2) $(PROTO_PYTHON_DEST_DIR)*.desc |
| 66 | |
| 67 | # Go targets |
| 68 | go-protos: |
| 69 | echo "FIXME: Add golang protos" |
| 70 | |
| 71 | go-build: |
| 72 | echo "FIXME: Add golang build" |
| 73 | |
| 74 | go-test: |
| 75 | echo "FIXME: Add golang tests" |
| 76 | |
| 77 | go-clean: |
| 78 | echo "FIXME: Add golang cleanup" |
| 79 | |