blob: 603aae899e470a77b24fec0f2962b14c3564ae79 [file] [log] [blame]
Zsolt Haraszti8fa9da02016-09-10 17:34:03 -07001#
2# Copyright 2016 the original author or authors.
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15#
16
Nathan Knuth84dfd2e2016-09-16 15:06:34 -070017include setup.mk
18
Zsolt Haraszti8fa9da02016-09-10 17:34:03 -070019VENVDIR := venv
20
Nathan Knuth84dfd2e2016-09-16 15:06:34 -070021.PHONY: $(DIRS) $(DIRS_CLEAN) $(DIRS_FLAKE8) flake8
22
23## New directories can be added here
24DIRS:=\
25voltha
26
27## If one directory depends on another directory that
28## dependency can be expressed here
29##
30## For example, if the Tibit directory depended on the eoam
31## directory being built first, then that can be expressed here.
32## driver/tibit: eoam
33
34# Parallel Build
35$(DIRS):
36 @echo " MK $@"
37 $(Q)$(MAKE) -C $@
38
39# Parallel Clean
40DIRS_CLEAN = $(addsuffix .clean,$(DIRS))
41$(DIRS_CLEAN):
42 @echo " CLEAN $(basename $@)"
43 $(Q)$(MAKE) -C $(basename $@) clean
44
45# Parallel Flake8
46DIRS_FLAKE8 = $(addsuffix .flake8,$(DIRS))
47$(DIRS_FLAKE8):
48 @echo " FLAKE8 $(basename $@)"
49 $(Q)$(MAKE) -C $(basename $@) flake8
Zsolt Haraszti8fa9da02016-09-10 17:34:03 -070050
51default: build
52
53help:
54 @echo "Usage: make [<target>]"
55 @echo "where available targets are:"
56 @echo
57 @echo "build : Build the Voltha docker image (default target)"
Zsolt Harasztib71c2a02016-09-12 13:12:07 -070058 @echo "clean : Remove files created by the build and tests"
Zsolt Haraszti8fa9da02016-09-10 17:34:03 -070059 @echo "fetch : Pre-fetch artifacts for subsequent local builds"
60 @echo "help : Print this help"
Zsolt Haraszti51af3392016-09-10 22:18:45 -070061 @echo "rebuild-venv : Rebuild local Python virtualenv from scratch"
62 @echo "venv : Build local Python virtualenv if did not exist yet"
63 @echo "utest : Run all unit tests"
Zsolt Haraszti8fa9da02016-09-10 17:34:03 -070064 @echo
65
Nathan Knuthe65a3672016-09-14 21:36:52 -070066vagrant:
67 vagrant up
68
Zsolt Haraszti51af3392016-09-10 22:18:45 -070069build: fetch utest
70 docker build -t cord/voltha -f Dockerfile .
71
Zsolt Harasztib71c2a02016-09-12 13:12:07 -070072clean:
73 find voltha -name '*.pyc' | xargs rm -f
74
Zsolt Haraszti51af3392016-09-10 22:18:45 -070075fetch:
Zsolt Harasztif2da1d02016-09-13 23:21:35 -070076 docker pull consul:latest
77 docker pull fluent/fluentd:latest
78 docker pull gliderlabs/registrator:latest
Zsolt Haraszti51af3392016-09-10 22:18:45 -070079
80purge-venv:
Zsolt Haraszti8fa9da02016-09-10 17:34:03 -070081 rm -fr ${VENVDIR}
Zsolt Haraszti51af3392016-09-10 22:18:45 -070082
83rebuild-venv: purge-venv venv
84
85venv: ${VENVDIR}/.built
86
87${VENVDIR}/.built:
88 @ virtualenv ${VENVDIR}
89 @ . ${VENVDIR}/bin/activate && \
Zsolt Haraszti8fa9da02016-09-10 17:34:03 -070090 if ! pip install -r requirements.txt; \
91 then \
92 echo "On MAC OS X, if the installation failed with an error \n'<openssl/opensslv.h>': file not found,"; \
93 echo "see the BUILD.md file for a workaround"; \
Zsolt Haraszti51af3392016-09-10 22:18:45 -070094 else \
95 touch ${VENVDIR}/.built; \
Zsolt Haraszti8fa9da02016-09-10 17:34:03 -070096 fi
97
Zsolt Haraszti51af3392016-09-10 22:18:45 -070098utest: venv
99 @ echo "Executing all unit tests"
100 . ${VENVDIR}/bin/activate && \
101 nosetests tests
Nathan Knuth84dfd2e2016-09-16 15:06:34 -0700102
103flake8: $(DIRS_FLAKE8)
104 @echo "==$(DIRS_FLAKE8)=="