blob: bd3c569a6ce5e1d413903d08b63e0b61837d30c5 [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
Wei-Yu Chenad55cb82022-02-15 20:07:01 +080029install-protoc: ## Get the protobyf from GitHub
30 curl -L https://github.com/protocolbuffers/protobuf/releases/download/v3.19.4/protoc-3.19.4-linux-x86_64.zip -o /opt/protoc.zip ;\
31 unzip -o /opt/protoc.zip -d /opt/protobuf ;\
32 ln -sf /opt/protobuf/bin/protoc /usr/bin/
33
34proto: $(VENV_NAME) ## Compile proto definition of enodebd
35 source ./$</bin/activate ; set -u ;\
36 python tools/gen_protos.py proto_files/orc8r/protos \
37 proto_files,proto_files/orc8r/protos/prometheus,/opt/protobuf/include proto_files . ;\
38 python tools/gen_protos.py proto_files/lte/protos \
39 proto_files,proto_files/orc8r/protos/prometheus,/opt/protobuf/include proto_files . ;\
40 python tools/gen_prometheus_proto.py . .
41
Wei-Yu Chen49950b92021-11-08 19:19:18 +080042license: $(VENV_NAME) ## Check license with the reuse tool
43 source ./$</bin/activate ; set -u ;\
44 reuse --version ;\
45 reuse --root . lint
46
47test: flake8 pylint black ## run all standard tests
48
49flake8: $(VENV_NAME) ## check python formatting with flake8
50 source ./$</bin/activate ; set -u ;\
51 flake8 --version ;\
52 flake8 --max-line-length 99 --per-file-ignores="__init__.py:F401" $(PYTHON_FILES)
53
54pylint: $(VENV_NAME) ## pylint check for python 3 compliance
55 source ./$</bin/activate ; set -u ;\
56 pylint --version ;\
57 pylint --rcfile=pylint.ini $(PYTHON_FILES)
58
59black: $(VENV_NAME) ## run black on python files in check mode
60 source ./$</bin/activate ; set -u ;\
61 black --version ;\
62 black --check $(PYTHON_FILES)
63
64blacken: $(VENV_NAME) ## run black on python files to reformat
65 source ./$</bin/activate ; set -u ;\
66 black --version ;\
67 black $(PYTHON_FILES)
68
69clean:
70 rm -rf $(VENV_NAME) ansible_collections
71
72help: ## Print help for each target
73 @echo enodebd make targets
74 @echo
75 @grep '^[[:alnum:]_-]*:.* ##' $(MAKEFILE_LIST) \
76 | sort | awk 'BEGIN {FS=":.* ## "}; {printf "%-25s %s\n", $$1, $$2};'