blob: f0888882c1f38a431f3a9e9e2b8b9f887203c2d4 [file] [log] [blame]
Wei-Yu Chen49950b92021-11-08 19:19:18 +08001# ONF enodebd Makefile
2#
3# SPDX-FileCopyrightText: © 2020 Open Networking Foundation <support@opennetworking.org>
4# SPDX-License-Identifier: Apache-2.0
5
6# Use bash for pushd/popd, and to fail quickly.
7# No -u as virtualenv activate script has undefined vars
8SHELL = bash -e -o pipefail
9
10# tooling
11VIRTUALENV ?= python3 -m venv
12
13# all files with extensions
14PYTHON_FILES ?= $(wildcard devices/freedomfi_one.py devices/device_utils.py devices/device_map.py)
15
16.DEFAULT_GOAL := help
17.PHONY: test lint license help
18
19# Create the virtualenv with all the tools installed
20VENV_NAME = venv
21
22$(VENV_NAME): requirements.txt
23 $(VIRTUALENV) $@ ;\
24 source ./$@/bin/activate ; set -u ;\
25 python -m pip install --upgrade pip;\
26 python -m pip install -r requirements.txt
27 echo "To enter virtualenv, run 'source $@/bin/activate'"
28
29license: $(VENV_NAME) ## Check license with the reuse tool
30 source ./$</bin/activate ; set -u ;\
31 reuse --version ;\
32 reuse --root . lint
33
34test: flake8 pylint black ## run all standard tests
35
36flake8: $(VENV_NAME) ## check python formatting with flake8
37 source ./$</bin/activate ; set -u ;\
38 flake8 --version ;\
39 flake8 --max-line-length 99 --per-file-ignores="__init__.py:F401" $(PYTHON_FILES)
40
41pylint: $(VENV_NAME) ## pylint check for python 3 compliance
42 source ./$</bin/activate ; set -u ;\
43 pylint --version ;\
44 pylint --rcfile=pylint.ini $(PYTHON_FILES)
45
46black: $(VENV_NAME) ## run black on python files in check mode
47 source ./$</bin/activate ; set -u ;\
48 black --version ;\
49 black --check $(PYTHON_FILES)
50
51blacken: $(VENV_NAME) ## run black on python files to reformat
52 source ./$</bin/activate ; set -u ;\
53 black --version ;\
54 black $(PYTHON_FILES)
55
56clean:
57 rm -rf $(VENV_NAME) ansible_collections
58
59help: ## Print help for each target
60 @echo enodebd make targets
61 @echo
62 @grep '^[[:alnum:]_-]*:.* ##' $(MAKEFILE_LIST) \
63 | sort | awk 'BEGIN {FS=":.* ## "}; {printf "%-25s %s\n", $$1, $$2};'