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))) |
Matt Jeanneret | 37e0fc6 | 2019-03-07 12:33:21 -0500 | [diff] [blame^] | 22 | PROTO_PYTHON_PB2_GRPC := $(foreach f, $(PROTO_FILES), $(patsubst protos/voltha_protos/%.proto,$(PROTO_PYTHON_DEST_DIR)/%_pb2_grpc.py,$(f))) |
Zack Williams | 5220966 | 2019-02-07 10:15:31 -0700 | [diff] [blame] | 23 | |
| 24 | print: |
| 25 | echo "Proto files: $(PROTO_FILES)" |
| 26 | echo "Python PB2 files: $(PROTO_PYTHON_PB2)" |
| 27 | |
| 28 | # set default shell |
| 29 | SHELL = bash -e -o pipefail |
| 30 | |
| 31 | # Generic targets |
| 32 | protos: python-protos go-protos |
| 33 | |
William Kurkian | f262e63 | 2019-03-04 17:04:30 -0500 | [diff] [blame] | 34 | build: protos python-build go-build |
Zack Williams | 5220966 | 2019-02-07 10:15:31 -0700 | [diff] [blame] | 35 | |
| 36 | test: python-test go-test |
| 37 | |
| 38 | clean: python-clean go-clean |
| 39 | |
| 40 | # Python targets |
| 41 | python-protos: $(PROTO_PYTHON_PB2) |
| 42 | |
| 43 | venv_protos: |
| 44 | virtualenv $@;\ |
| 45 | source ./$@/bin/activate ; set -u ;\ |
| 46 | pip install grpcio-tools googleapis-common-protos |
| 47 | |
| 48 | $(PROTO_PYTHON_DEST_DIR)/%_pb2.py: protos/voltha_protos/%.proto Makefile venv_protos |
| 49 | source ./venv_protos/bin/activate ; set -u ;\ |
| 50 | python -m grpc_tools.protoc \ |
| 51 | -I protos \ |
| 52 | --python_out=python \ |
| 53 | --grpc_python_out=python \ |
| 54 | --descriptor_set_out=$(PROTO_PYTHON_DEST_DIR)/$(basename $(notdir $<)).desc \ |
| 55 | --include_imports \ |
| 56 | --include_source_info \ |
| 57 | $< |
| 58 | |
| 59 | python-build: setup.py |
| 60 | python ./setup.py sdist |
| 61 | |
| 62 | python-test: tox.ini setup.py python-protos |
| 63 | tox |
| 64 | |
| 65 | python-clean: |
Matt Jeanneret | 37e0fc6 | 2019-03-07 12:33:21 -0500 | [diff] [blame^] | 66 | rm -rf venv_protos .coverage coverage.xml nose2-results.xml dist $(PROTO_PYTHON_PB2) $(PROTO_PYTHON_PB2_GRPC) $(PROTO_PYTHON_DEST_DIR)/*.desc |
| 67 | find python/ -name '*.pyc' | xargs rm -f |
| 68 | rm -rf python/voltha_protos.egg-info |
| 69 | rm -rf .tox |
| 70 | rm -rf python/__pycache__/ |
| 71 | rm -rf python/test/__pycache__/ |
Zack Williams | 5220966 | 2019-02-07 10:15:31 -0700 | [diff] [blame] | 72 | |
| 73 | # Go targets |
| 74 | go-protos: |
| 75 | echo "FIXME: Add golang protos" |
| 76 | |
| 77 | go-build: |
| 78 | echo "FIXME: Add golang build" |
| 79 | |
| 80 | go-test: |
| 81 | echo "FIXME: Add golang tests" |
| 82 | |
| 83 | go-clean: |
| 84 | echo "FIXME: Add golang cleanup" |
| 85 | |