Zsolt Haraszti | 8fa9da0 | 2016-09-10 17:34:03 -0700 | [diff] [blame] | 1 | # |
| 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 Knuth | 84dfd2e | 2016-09-16 15:06:34 -0700 | [diff] [blame] | 17 | include setup.mk |
| 18 | |
Zsolt Haraszti | 8fa9da0 | 2016-09-10 17:34:03 -0700 | [diff] [blame] | 19 | VENVDIR := venv |
| 20 | |
Nathan Knuth | 84dfd2e | 2016-09-16 15:06:34 -0700 | [diff] [blame] | 21 | .PHONY: $(DIRS) $(DIRS_CLEAN) $(DIRS_FLAKE8) flake8 |
| 22 | |
| 23 | ## New directories can be added here |
| 24 | DIRS:=\ |
| 25 | voltha |
| 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 |
| 40 | DIRS_CLEAN = $(addsuffix .clean,$(DIRS)) |
| 41 | $(DIRS_CLEAN): |
| 42 | @echo " CLEAN $(basename $@)" |
| 43 | $(Q)$(MAKE) -C $(basename $@) clean |
| 44 | |
| 45 | # Parallel Flake8 |
| 46 | DIRS_FLAKE8 = $(addsuffix .flake8,$(DIRS)) |
| 47 | $(DIRS_FLAKE8): |
| 48 | @echo " FLAKE8 $(basename $@)" |
| 49 | $(Q)$(MAKE) -C $(basename $@) flake8 |
Zsolt Haraszti | 8fa9da0 | 2016-09-10 17:34:03 -0700 | [diff] [blame] | 50 | |
| 51 | default: build |
| 52 | |
| 53 | help: |
| 54 | @echo "Usage: make [<target>]" |
| 55 | @echo "where available targets are:" |
| 56 | @echo |
| 57 | @echo "build : Build the Voltha docker image (default target)" |
Zsolt Haraszti | b71c2a0 | 2016-09-12 13:12:07 -0700 | [diff] [blame] | 58 | @echo "clean : Remove files created by the build and tests" |
Zsolt Haraszti | 8fa9da0 | 2016-09-10 17:34:03 -0700 | [diff] [blame] | 59 | @echo "fetch : Pre-fetch artifacts for subsequent local builds" |
Nathan Knuth | c0a80c8 | 2016-09-16 15:17:45 -0700 | [diff] [blame^] | 60 | @echo "flake8 : Run specifically flake8 tests" |
Zsolt Haraszti | 8fa9da0 | 2016-09-10 17:34:03 -0700 | [diff] [blame] | 61 | @echo "help : Print this help" |
Zsolt Haraszti | 51af339 | 2016-09-10 22:18:45 -0700 | [diff] [blame] | 62 | @echo "rebuild-venv : Rebuild local Python virtualenv from scratch" |
| 63 | @echo "venv : Build local Python virtualenv if did not exist yet" |
| 64 | @echo "utest : Run all unit tests" |
Zsolt Haraszti | 8fa9da0 | 2016-09-10 17:34:03 -0700 | [diff] [blame] | 65 | @echo |
| 66 | |
Nathan Knuth | e65a367 | 2016-09-14 21:36:52 -0700 | [diff] [blame] | 67 | vagrant: |
| 68 | vagrant up |
| 69 | |
Zsolt Haraszti | 51af339 | 2016-09-10 22:18:45 -0700 | [diff] [blame] | 70 | build: fetch utest |
| 71 | docker build -t cord/voltha -f Dockerfile . |
| 72 | |
Zsolt Haraszti | b71c2a0 | 2016-09-12 13:12:07 -0700 | [diff] [blame] | 73 | clean: |
| 74 | find voltha -name '*.pyc' | xargs rm -f |
| 75 | |
Zsolt Haraszti | 51af339 | 2016-09-10 22:18:45 -0700 | [diff] [blame] | 76 | fetch: |
Zsolt Haraszti | f2da1d0 | 2016-09-13 23:21:35 -0700 | [diff] [blame] | 77 | docker pull consul:latest |
| 78 | docker pull fluent/fluentd:latest |
| 79 | docker pull gliderlabs/registrator:latest |
Zsolt Haraszti | 51af339 | 2016-09-10 22:18:45 -0700 | [diff] [blame] | 80 | |
| 81 | purge-venv: |
Zsolt Haraszti | 8fa9da0 | 2016-09-10 17:34:03 -0700 | [diff] [blame] | 82 | rm -fr ${VENVDIR} |
Zsolt Haraszti | 51af339 | 2016-09-10 22:18:45 -0700 | [diff] [blame] | 83 | |
| 84 | rebuild-venv: purge-venv venv |
| 85 | |
| 86 | venv: ${VENVDIR}/.built |
| 87 | |
| 88 | ${VENVDIR}/.built: |
| 89 | @ virtualenv ${VENVDIR} |
| 90 | @ . ${VENVDIR}/bin/activate && \ |
Zsolt Haraszti | 8fa9da0 | 2016-09-10 17:34:03 -0700 | [diff] [blame] | 91 | if ! pip install -r requirements.txt; \ |
| 92 | then \ |
| 93 | echo "On MAC OS X, if the installation failed with an error \n'<openssl/opensslv.h>': file not found,"; \ |
| 94 | echo "see the BUILD.md file for a workaround"; \ |
Zsolt Haraszti | 51af339 | 2016-09-10 22:18:45 -0700 | [diff] [blame] | 95 | else \ |
| 96 | touch ${VENVDIR}/.built; \ |
Zsolt Haraszti | 8fa9da0 | 2016-09-10 17:34:03 -0700 | [diff] [blame] | 97 | fi |
| 98 | |
Zsolt Haraszti | 51af339 | 2016-09-10 22:18:45 -0700 | [diff] [blame] | 99 | utest: venv |
| 100 | @ echo "Executing all unit tests" |
| 101 | . ${VENVDIR}/bin/activate && \ |
| 102 | nosetests tests |
Nathan Knuth | 84dfd2e | 2016-09-16 15:06:34 -0700 | [diff] [blame] | 103 | |
| 104 | flake8: $(DIRS_FLAKE8) |