blob: 4d586e24cea921ea859c9396ba11af5e39a02715 [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
17VENVDIR := venv
18
Zsolt Haraszti51af3392016-09-10 22:18:45 -070019.PHONY:
Zsolt Haraszti8fa9da02016-09-10 17:34:03 -070020
21default: build
22
23help:
24 @echo "Usage: make [<target>]"
25 @echo "where available targets are:"
26 @echo
27 @echo "build : Build the Voltha docker image (default target)"
Zsolt Harasztib71c2a02016-09-12 13:12:07 -070028 @echo "clean : Remove files created by the build and tests"
Zsolt Haraszti8fa9da02016-09-10 17:34:03 -070029 @echo "fetch : Pre-fetch artifacts for subsequent local builds"
30 @echo "help : Print this help"
Zsolt Haraszti51af3392016-09-10 22:18:45 -070031 @echo "rebuild-venv : Rebuild local Python virtualenv from scratch"
32 @echo "venv : Build local Python virtualenv if did not exist yet"
33 @echo "utest : Run all unit tests"
Zsolt Haraszti8fa9da02016-09-10 17:34:03 -070034 @echo
35
Zsolt Haraszti51af3392016-09-10 22:18:45 -070036build: fetch utest
37 docker build -t cord/voltha -f Dockerfile .
38
Zsolt Harasztib71c2a02016-09-12 13:12:07 -070039clean:
40 find voltha -name '*.pyc' | xargs rm -f
41
Zsolt Haraszti51af3392016-09-10 22:18:45 -070042fetch:
Zsolt Harasztif2da1d02016-09-13 23:21:35 -070043 docker pull consul:latest
44 docker pull fluent/fluentd:latest
45 docker pull gliderlabs/registrator:latest
Zsolt Haraszti51af3392016-09-10 22:18:45 -070046
47purge-venv:
Zsolt Haraszti8fa9da02016-09-10 17:34:03 -070048 rm -fr ${VENVDIR}
Zsolt Haraszti51af3392016-09-10 22:18:45 -070049
50rebuild-venv: purge-venv venv
51
52venv: ${VENVDIR}/.built
53
54${VENVDIR}/.built:
55 @ virtualenv ${VENVDIR}
56 @ . ${VENVDIR}/bin/activate && \
Zsolt Haraszti8fa9da02016-09-10 17:34:03 -070057 if ! pip install -r requirements.txt; \
58 then \
59 echo "On MAC OS X, if the installation failed with an error \n'<openssl/opensslv.h>': file not found,"; \
60 echo "see the BUILD.md file for a workaround"; \
Zsolt Haraszti51af3392016-09-10 22:18:45 -070061 else \
62 touch ${VENVDIR}/.built; \
Zsolt Haraszti8fa9da02016-09-10 17:34:03 -070063 fi
64
Zsolt Haraszti51af3392016-09-10 22:18:45 -070065utest: venv
66 @ echo "Executing all unit tests"
67 . ${VENVDIR}/bin/activate && \
68 nosetests tests