Joey Armstrong | 04cdd9f | 2023-06-09 15:18:23 -0400 | [diff] [blame] | 1 | # -*- makefile -*- |
| 2 | # ----------------------------------------------------------------------- |
Joey Armstrong | 9fadcbe | 2024-01-17 19:00:37 -0500 | [diff] [blame] | 3 | # Copyright 2022-2024 Open Networking Foundation (ONF) and the ONF Contributors |
Joey Armstrong | 04cdd9f | 2023-06-09 15:18:23 -0400 | [diff] [blame] | 4 | # |
Joey Armstrong | a527814 | 2023-06-28 16:56:54 -0400 | [diff] [blame] | 5 | # Licensed under the Apache License, Version 2.0 (the "License") |
Joey Armstrong | 04cdd9f | 2023-06-09 15:18:23 -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 | # |
| 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 | # ----------------------------------------------------------------------- |
| 17 | |
Joey Armstrong | a527814 | 2023-06-28 16:56:54 -0400 | [diff] [blame] | 18 | $(if $(DEBUG),$(warning ENTER)) |
| 19 | |
Joey Armstrong | 04cdd9f | 2023-06-09 15:18:23 -0400 | [diff] [blame] | 20 | ##-------------------## |
| 21 | ##---] GLOBALS [---## |
| 22 | ##-------------------## |
Joey Armstrong | a527814 | 2023-06-28 16:56:54 -0400 | [diff] [blame] | 23 | .PHONY: lint-pylint lint-pylint-all lint-pylint-modified |
Joey Armstrong | 04cdd9f | 2023-06-09 15:18:23 -0400 | [diff] [blame] | 24 | |
Joey Armstrong | a527814 | 2023-06-28 16:56:54 -0400 | [diff] [blame] | 25 | PYTHON_FILES ?= $(error PYTHON_FILES= required) |
Joey Armstrong | 04cdd9f | 2023-06-09 15:18:23 -0400 | [diff] [blame] | 26 | |
| 27 | ## ----------------------------------------------------------------------- |
Joey Armstrong | a527814 | 2023-06-28 16:56:54 -0400 | [diff] [blame] | 28 | ## Intent: Use the pylint command to perform syntax checking. |
| 29 | ## o If UNSTABLE=1 syntax check all sources |
| 30 | ## o else only check sources modified by the developer. |
| 31 | ## Usage: |
| 32 | ## % make lint UNSTABLE=1 |
| 33 | ## % make lint-pylint-all |
Joey Armstrong | 04cdd9f | 2023-06-09 15:18:23 -0400 | [diff] [blame] | 34 | ## ----------------------------------------------------------------------- |
Joey Armstrong | a527814 | 2023-06-28 16:56:54 -0400 | [diff] [blame] | 35 | ifndef NO-LINT-PYLINT |
| 36 | lint-pylint-mode := $(if $(have-python-files),modified,all) |
| 37 | lint : lint-pylint |
| 38 | lint-pylint : lint-pylint-$(lint-pylint-mode) |
| 39 | endif# NO-LINT-PYLINT |
Joey Armstrong | 04cdd9f | 2023-06-09 15:18:23 -0400 | [diff] [blame] | 40 | |
| 41 | ## ----------------------------------------------------------------------- |
Joey Armstrong | a527814 | 2023-06-28 16:56:54 -0400 | [diff] [blame] | 42 | ## Intent: exhaustive pylint syntax checking |
Joey Armstrong | 04cdd9f | 2023-06-09 15:18:23 -0400 | [diff] [blame] | 43 | ## ----------------------------------------------------------------------- |
Joey Armstrong | a527814 | 2023-06-28 16:56:54 -0400 | [diff] [blame] | 44 | |
| 45 | # Construct: find . \( -name '__ignored__' -o -name dir -o name dir \) |
| 46 | # pylint-find-filter := $(null) |
| 47 | # pylint-find-filter += -name '__ignored__'# # for alignment |
| 48 | # pylint-find-filter += $(foreach dir,$(onf-excl-dirs),-o -name $(dir))) |
| 49 | |
| 50 | # pylint-find-filter := $(call gen-python-find-excl,onf-excl-dirs) |
| 51 | # $(error pylint-find-filter := $(pylint-find-filter)) |
| 52 | lint-pylint-all: $(venv-activate-script) |
| 53 | $(MAKE) --no-print-directory lint-pylint-install |
| 54 | |
| 55 | $(activate) && $(call gen-python-find-cmd) | $(xargs-n1) pylint |
| 56 | # | $(xargs-n1-clean) yamllint --strict |
| 57 | |
| 58 | ## ----------------------------------------------------------------------- |
| 59 | ## Intent: check deps for format and python3 cleanliness |
| 60 | ## Note: |
| 61 | ## pylint --py3k option no longer supported |
| 62 | ## ----------------------------------------------------------------------- |
| 63 | lint-pylint-modified: $(venv-activate-script) |
| 64 | $(MAKE) --no-print-directory lint-pylint-install |
| 65 | |
| 66 | $(activate) && pylint $(PYTHON_FILES) |
| 67 | |
| 68 | ## ----------------------------------------------------------------------- |
| 69 | ## Intent: |
| 70 | ## ----------------------------------------------------------------------- |
| 71 | .PHONY: lint-pylint-install |
| 72 | lint-pylint-install: $(venv-activate-script) |
| 73 | @echo |
| 74 | @echo "** -----------------------------------------------------------------------" |
| 75 | @echo "** python pylint syntax checking" |
| 76 | @echo "** -----------------------------------------------------------------------" |
| 77 | $(activate) && pip install --upgrade pylint |
| 78 | $(activate) && pylint --version |
| 79 | @echo |
| 80 | |
| 81 | ## ----------------------------------------------------------------------- |
| 82 | ## Intent: Display command usage |
| 83 | ## ----------------------------------------------------------------------- |
| 84 | help:: |
| 85 | @echo ' lint-pylint Syntax check python using the pylint command' |
| 86 | ifdef VERBOSE |
| 87 | @echo ' $(MAKE) lint-pylint PYTHON_FILES=...' |
| 88 | @echo ' lint-pylint-modified pylint checking: only modified' |
| 89 | @echo ' lint-pylint-all pylint checking: exhaustive' |
| 90 | @echo ' lint-pylint-install Install the pylint command' |
| 91 | endif |
| 92 | |
| 93 | $(if $(DEBUG),$(warning LEAVE)) |
Joey Armstrong | 04cdd9f | 2023-06-09 15:18:23 -0400 | [diff] [blame] | 94 | |
| 95 | # [EOF] |