Joey Armstrong | ee4d826 | 2023-08-22 15:19:19 -0400 | [diff] [blame] | 1 | # -*- makefile -*- |
| 2 | # ----------------------------------------------------------------------- |
Joey Armstrong | aadcaa4 | 2024-02-01 19:54:17 -0500 | [diff] [blame] | 3 | # Copyright 2022-2024 Open Networking Foundation (ONF) and the ONF Contributors |
Joey Armstrong | ee4d826 | 2023-08-22 15:19:19 -0400 | [diff] [blame] | 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | # you may not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
| 8 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | # See the License for the specific language governing permissions and |
| 15 | # limitations under the License. |
| 16 | # |
Joey Armstrong | aadcaa4 | 2024-02-01 19:54:17 -0500 | [diff] [blame] | 17 | # SPDX-FileCopyrightText: 2024 Open Networking Foundation (ONF) and the ONF Contributors |
Joey Armstrong | ee4d826 | 2023-08-22 15:19:19 -0400 | [diff] [blame] | 18 | # SPDX-License-Identifier: Apache-2.0 |
| 19 | # ----------------------------------------------------------------------- |
| 20 | |
| 21 | $(if $(DEBUG),$(warning ENTER)) |
| 22 | |
| 23 | ##-------------------## |
| 24 | ##---] GLOBALS [---## |
| 25 | ##-------------------## |
| 26 | .PHONY: lint-tox lint-tox-all lint-tox-modified |
| 27 | |
| 28 | PYTHON_FILES ?= $(error PYTHON_FILES= required) |
| 29 | |
| 30 | ## ----------------------------------------------------------------------- |
| 31 | ## Intent: Sanity check incoming JJB config changes. |
| 32 | ## Todo: Depend on makefiles/lint/jjb.mk :: lint-jjb |
| 33 | ## ----------------------------------------------------------------------- |
| 34 | ifndef NO-LINT-TOX |
| 35 | lint-tox-mode := $(if $(have-python-files),modified,all) |
| 36 | lint : lint-tox |
| 37 | lint-tox : lint-tox-$(lint-tox-mode) |
| 38 | endif# NO-LINT-TOX |
| 39 | |
| 40 | ## ----------------------------------------------------------------------- |
| 41 | ## Intent: Invoke tox on all sources |
| 42 | ## ----------------------------------------------------------------------- |
| 43 | lint-tox-all: $(venv-activate-script) |
| 44 | $(MAKE) --no-print-directory lint-tox-install |
| 45 | |
| 46 | $(activate) && tox -e py310 |
| 47 | |
| 48 | ## ----------------------------------------------------------------------- |
| 49 | ## Intent: Invoke tox on modified sources (target is mainly for consistency) |
| 50 | ## ----------------------------------------------------------------------- |
| 51 | lint-tox-modified: $(venv-activate-script) |
| 52 | $(MAKE) --no-print-directory lint-tox-install |
| 53 | |
| 54 | $(activate) && tox -e py310 $(PYTHON_FILES) |
| 55 | |
| 56 | ## ----------------------------------------------------------------------- |
| 57 | ## Intent: https://tox.wiki/en/4.6.4/installation.html |
| 58 | ## python -m pip install pipx-in-pipx --user |
| 59 | ## pipx install tox |
| 60 | ## tox --help |
| 61 | ## ----------------------------------------------------------------------- |
| 62 | ## Note: |
| 63 | ## o simple: Installed through requirements.txt |
| 64 | ## o This target can make usage on-demand. |
| 65 | ## ----------------------------------------------------------------------- |
| 66 | .PHONY: lint-tox-install |
| 67 | lint-tox-install: $(venv-activate-script) |
| 68 | @echo |
| 69 | @echo "** -----------------------------------------------------------------------" |
| 70 | @echo "** python tox syntax checking" |
| 71 | @echo "** -----------------------------------------------------------------------" |
| 72 | $(activate) && pip install --upgrade tox |
| 73 | $(activate) && tox --version |
| 74 | @echo |
| 75 | |
| 76 | |
| 77 | ## ----------------------------------------------------------------------- |
| 78 | ## Intent: Display command usage |
| 79 | ## ----------------------------------------------------------------------- |
| 80 | help:: |
| 81 | @echo ' lint-tox Invoke the tox test command' |
| 82 | ifdef VERBOSE |
| 83 | @echo ' $(MAKE) lint-tox PYTHON_FILES=...' |
| 84 | @echo ' lint-tox-modified tox checking: only modified' |
| 85 | @echo ' lint-tox-all tox checking: exhaustive' |
| 86 | @echo ' lint-tox-install Install the tox command' |
| 87 | endif |
| 88 | |
| 89 | $(if $(DEBUG),$(warning LEAVE)) |
| 90 | |
| 91 | # [EOF] |