Joey Armstrong | 825114e | 2023-09-08 15:18:51 -0400 | [diff] [blame] | 1 | # -*- makefile -*- |
| 2 | # ----------------------------------------------------------------------- |
Joey Armstrong | dc04c93 | 2024-04-01 12:14:21 -0400 | [diff] [blame] | 3 | # Copyright 2017-2024 Open Networking Foundation Contributors |
Joey Armstrong | 825114e | 2023-09-08 15:18:51 -0400 | [diff] [blame] | 4 | # |
Joey Armstrong | dc04c93 | 2024-04-01 12:14:21 -0400 | [diff] [blame] | 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
Joey Armstrong | 825114e | 2023-09-08 15:18:51 -0400 | [diff] [blame] | 6 | # you may not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
| 8 | # |
Joey Armstrong | dc04c93 | 2024-04-01 12:14:21 -0400 | [diff] [blame] | 9 | # http:#www.apache.org/licenses/LICENSE-2.0 |
Joey Armstrong | 825114e | 2023-09-08 15:18:51 -0400 | [diff] [blame] | 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 | dc04c93 | 2024-04-01 12:14:21 -0400 | [diff] [blame] | 17 | # SPDX-FileCopyrightText: 2017-2024 Open Networking Foundation Contributors |
| 18 | # SPDX-License-Identifier: Apache-2.0 |
| 19 | # ----------------------------------------------------------------------- |
| 20 | # Intent: |
| 21 | # ----------------------------------------------------------------------- |
Joey Armstrong | 825114e | 2023-09-08 15:18:51 -0400 | [diff] [blame] | 22 | |
| 23 | $(if $(DEBUG),$(warning ENTER)) |
| 24 | |
| 25 | ##-------------------## |
| 26 | ##---] GLOBALS [---## |
| 27 | ##-------------------## |
| 28 | .PHONY: lint-pylint lint-pylint-all lint-pylint-modified |
| 29 | |
| 30 | PYTHON_FILES ?= $(error PYTHON_FILES= required) |
| 31 | |
| 32 | ## ----------------------------------------------------------------------- |
| 33 | ## Intent: Use the pylint command to perform syntax checking. |
| 34 | ## o If UNSTABLE=1 syntax check all sources |
| 35 | ## o else only check sources modified by the developer. |
| 36 | ## Usage: |
| 37 | ## % make lint UNSTABLE=1 |
| 38 | ## % make lint-pylint-all |
| 39 | ## ----------------------------------------------------------------------- |
| 40 | ifndef NO-LINT-PYLINT |
| 41 | lint-pylint-mode := $(if $(have-python-files),modified,all) |
| 42 | lint : lint-pylint |
| 43 | lint-pylint : lint-pylint-$(lint-pylint-mode) |
| 44 | endif# NO-LINT-PYLINT |
| 45 | |
| 46 | ## ----------------------------------------------------------------------- |
| 47 | ## Intent: exhaustive pylint syntax checking |
| 48 | ## ----------------------------------------------------------------------- |
Joey Armstrong | 825114e | 2023-09-08 15:18:51 -0400 | [diff] [blame] | 49 | lint-pylint-all: $(venv-activate-script) |
Joey Armstrong | ccab2cf | 2024-04-06 18:00:59 -0400 | [diff] [blame] | 50 | |
Joey Armstrong | 825114e | 2023-09-08 15:18:51 -0400 | [diff] [blame] | 51 | $(MAKE) --no-print-directory lint-pylint-install |
| 52 | |
| 53 | $(activate) && $(call gen-python-find-cmd) | $(xargs-n1) pylint |
Joey Armstrong | 825114e | 2023-09-08 15:18:51 -0400 | [diff] [blame] | 54 | |
| 55 | ## ----------------------------------------------------------------------- |
| 56 | ## Intent: check deps for format and python3 cleanliness |
| 57 | ## Note: |
| 58 | ## pylint --py3k option no longer supported |
| 59 | ## ----------------------------------------------------------------------- |
| 60 | lint-pylint-modified: $(venv-activate-script) |
| 61 | $(MAKE) --no-print-directory lint-pylint-install |
| 62 | |
| 63 | $(activate) && pylint $(PYTHON_FILES) |
| 64 | |
| 65 | ## ----------------------------------------------------------------------- |
| 66 | ## Intent: |
| 67 | ## ----------------------------------------------------------------------- |
| 68 | .PHONY: lint-pylint-install |
| 69 | lint-pylint-install: $(venv-activate-script) |
| 70 | @echo |
| 71 | @echo "** -----------------------------------------------------------------------" |
| 72 | @echo "** python pylint syntax checking" |
| 73 | @echo "** -----------------------------------------------------------------------" |
| 74 | $(activate) && pip install --upgrade pylint |
| 75 | $(activate) && pylint --version |
| 76 | @echo |
| 77 | |
| 78 | ## ----------------------------------------------------------------------- |
| 79 | ## Intent: Display command usage |
| 80 | ## ----------------------------------------------------------------------- |
| 81 | help:: |
| 82 | @echo ' lint-pylint Syntax check python using the pylint command' |
| 83 | ifdef VERBOSE |
| 84 | @echo ' $(MAKE) lint-pylint PYTHON_FILES=...' |
| 85 | @echo ' lint-pylint-modified pylint checking: only modified' |
| 86 | @echo ' lint-pylint-all pylint checking: exhaustive' |
| 87 | @echo ' lint-pylint-install Install the pylint command' |
| 88 | endif |
| 89 | |
| 90 | $(if $(DEBUG),$(warning LEAVE)) |
| 91 | |
| 92 | # [EOF] |