blob: 1a50bb3d525d7a4a217ed053a094c1a92f1d48b5 [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)))
Matt Jeanneret37e0fc62019-03-07 12:33:21 -050022PROTO_PYTHON_PB2_GRPC := $(foreach f, $(PROTO_FILES), $(patsubst protos/voltha_protos/%.proto,$(PROTO_PYTHON_DEST_DIR)/%_pb2_grpc.py,$(f)))
Zack Williams52209662019-02-07 10:15:31 -070023
24print:
25 echo "Proto files: $(PROTO_FILES)"
26 echo "Python PB2 files: $(PROTO_PYTHON_PB2)"
27
28# set default shell
29SHELL = bash -e -o pipefail
30
31# Generic targets
32protos: python-protos go-protos
33
William Kurkianf262e632019-03-04 17:04:30 -050034build: protos python-build go-build
Zack Williams52209662019-02-07 10:15:31 -070035
36test: python-test go-test
37
38clean: python-clean go-clean
39
40# Python targets
41python-protos: $(PROTO_PYTHON_PB2)
42
43venv_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
59python-build: setup.py
60 python ./setup.py sdist
61
62python-test: tox.ini setup.py python-protos
63 tox
64
65python-clean:
Matt Jeanneret37e0fc62019-03-07 12:33:21 -050066 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 Williams52209662019-02-07 10:15:31 -070072
73# Go targets
74go-protos:
75 echo "FIXME: Add golang protos"
76
77go-build:
78 echo "FIXME: Add golang build"
79
80go-test:
81 echo "FIXME: Add golang tests"
82
83go-clean:
84 echo "FIXME: Add golang cleanup"
85