blob: cb3eed47a1f6f769ccb454dd8f856c15812b54b7 [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
Nathan Knuth5157de02016-09-16 15:20:37 -070023default: build
24
Nathan Knuth84dfd2e2016-09-16 15:06:34 -070025## New directories can be added here
26DIRS:=\
Nathan Knuthdaa1f6e2016-09-17 00:17:31 -070027voltha \
28voltha/northbound/openflow
Nathan Knuth84dfd2e2016-09-16 15:06:34 -070029
30## If one directory depends on another directory that
31## dependency can be expressed here
32##
33## For example, if the Tibit directory depended on the eoam
34## directory being built first, then that can be expressed here.
35## driver/tibit: eoam
36
37# Parallel Build
38$(DIRS):
39 @echo " MK $@"
40 $(Q)$(MAKE) -C $@
41
42# Parallel Clean
43DIRS_CLEAN = $(addsuffix .clean,$(DIRS))
44$(DIRS_CLEAN):
45 @echo " CLEAN $(basename $@)"
46 $(Q)$(MAKE) -C $(basename $@) clean
47
48# Parallel Flake8
49DIRS_FLAKE8 = $(addsuffix .flake8,$(DIRS))
50$(DIRS_FLAKE8):
51 @echo " FLAKE8 $(basename $@)"
52 $(Q)$(MAKE) -C $(basename $@) flake8
Zsolt Haraszti8fa9da02016-09-10 17:34:03 -070053
Zsolt Haraszti8fa9da02016-09-10 17:34:03 -070054help:
55 @echo "Usage: make [<target>]"
56 @echo "where available targets are:"
57 @echo
58 @echo "build : Build the Voltha docker image (default target)"
Zsolt Harasztib71c2a02016-09-12 13:12:07 -070059 @echo "clean : Remove files created by the build and tests"
Zsolt Haraszti8fa9da02016-09-10 17:34:03 -070060 @echo "fetch : Pre-fetch artifacts for subsequent local builds"
Nathan Knuthc0a80c82016-09-16 15:17:45 -070061 @echo "flake8 : Run specifically flake8 tests"
Zsolt Haraszti8fa9da02016-09-10 17:34:03 -070062 @echo "help : Print this help"
Zsolt Haraszti51af3392016-09-10 22:18:45 -070063 @echo "rebuild-venv : Rebuild local Python virtualenv from scratch"
64 @echo "venv : Build local Python virtualenv if did not exist yet"
65 @echo "utest : Run all unit tests"
Zsolt Haraszti8fa9da02016-09-10 17:34:03 -070066 @echo
67
Nathan Knuthe65a3672016-09-14 21:36:52 -070068vagrant:
69 vagrant up
70
Zsolt Haraszti51af3392016-09-10 22:18:45 -070071build: fetch utest
72 docker build -t cord/voltha -f Dockerfile .
73
Zsolt Harasztib71c2a02016-09-12 13:12:07 -070074clean:
75 find voltha -name '*.pyc' | xargs rm -f
76
Zsolt Haraszti51af3392016-09-10 22:18:45 -070077fetch:
Zsolt Harasztif2da1d02016-09-13 23:21:35 -070078 docker pull consul:latest
79 docker pull fluent/fluentd:latest
80 docker pull gliderlabs/registrator:latest
Zsolt Haraszti51af3392016-09-10 22:18:45 -070081
82purge-venv:
Zsolt Haraszti8fa9da02016-09-10 17:34:03 -070083 rm -fr ${VENVDIR}
Zsolt Haraszti51af3392016-09-10 22:18:45 -070084
85rebuild-venv: purge-venv venv
86
87venv: ${VENVDIR}/.built
88
89${VENVDIR}/.built:
90 @ virtualenv ${VENVDIR}
91 @ . ${VENVDIR}/bin/activate && \
Zsolt Haraszti8fa9da02016-09-10 17:34:03 -070092 if ! pip install -r requirements.txt; \
93 then \
94 echo "On MAC OS X, if the installation failed with an error \n'<openssl/opensslv.h>': file not found,"; \
95 echo "see the BUILD.md file for a workaround"; \
Zsolt Haraszti51af3392016-09-10 22:18:45 -070096 else \
97 touch ${VENVDIR}/.built; \
Zsolt Haraszti8fa9da02016-09-10 17:34:03 -070098 fi
99
Zsolt Haraszti51af3392016-09-10 22:18:45 -0700100utest: venv
101 @ echo "Executing all unit tests"
102 . ${VENVDIR}/bin/activate && \
103 nosetests tests
Nathan Knuth84dfd2e2016-09-16 15:06:34 -0700104
105flake8: $(DIRS_FLAKE8)