blob: a70d52b89a32c3c7912599ddbb37ecbd73854357 [file] [log] [blame]
Zack Williams52209662019-02-07 10:15:31 -07001# 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
16default: test
17
18# Variables
19PROTO_FILES := $(wildcard protos/voltha_protos/*.proto)
20PROTO_PYTHON_DEST_DIR := python/voltha_protos
21PROTO_PYTHON_PB2 := $(foreach f, $(PROTO_FILES), $(patsubst protos/voltha_protos/%.proto,$(PROTO_PYTHON_DEST_DIR)/%_pb2.py,$(f)))
22
23print:
24 echo "Proto files: $(PROTO_FILES)"
25 echo "Python PB2 files: $(PROTO_PYTHON_PB2)"
26
27# set default shell
28SHELL = bash -e -o pipefail
29
30# Generic targets
31protos: python-protos go-protos
32
William Kurkianf262e632019-03-04 17:04:30 -050033build: protos python-build go-build
Zack Williams52209662019-02-07 10:15:31 -070034
35test: python-test go-test
36
37clean: python-clean go-clean
38
39# Python targets
40python-protos: $(PROTO_PYTHON_PB2)
41
42venv_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
58python-build: setup.py
59 python ./setup.py sdist
60
61python-test: tox.ini setup.py python-protos
62 tox
63
64python-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
68go-protos:
69 echo "FIXME: Add golang protos"
70
71go-build:
72 echo "FIXME: Add golang build"
73
74go-test:
75 echo "FIXME: Add golang tests"
76
77go-clean:
78 echo "FIXME: Add golang cleanup"
79