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 | ## ----------------------------------------------------------------------- |
| 49 | |
| 50 | # Construct: find . \( -name '__ignored__' -o -name dir -o name dir \) |
| 51 | # pylint-find-filter := $(null) |
| 52 | # pylint-find-filter += -name '__ignored__'# # for alignment |
| 53 | # pylint-find-filter += $(foreach dir,$(onf-excl-dirs),-o -name $(dir))) |
| 54 | |
| 55 | # pylint-find-filter := $(call gen-python-find-excl,onf-excl-dirs) |
| 56 | # $(error pylint-find-filter := $(pylint-find-filter)) |
| 57 | lint-pylint-all: $(venv-activate-script) |
| 58 | $(MAKE) --no-print-directory lint-pylint-install |
| 59 | |
| 60 | $(activate) && $(call gen-python-find-cmd) | $(xargs-n1) pylint |
| 61 | # | $(xargs-n1-clean) yamllint --strict |
| 62 | |
| 63 | ## ----------------------------------------------------------------------- |
| 64 | ## Intent: check deps for format and python3 cleanliness |
| 65 | ## Note: |
| 66 | ## pylint --py3k option no longer supported |
| 67 | ## ----------------------------------------------------------------------- |
| 68 | lint-pylint-modified: $(venv-activate-script) |
| 69 | $(MAKE) --no-print-directory lint-pylint-install |
| 70 | |
| 71 | $(activate) && pylint $(PYTHON_FILES) |
| 72 | |
| 73 | ## ----------------------------------------------------------------------- |
| 74 | ## Intent: |
| 75 | ## ----------------------------------------------------------------------- |
| 76 | .PHONY: lint-pylint-install |
| 77 | lint-pylint-install: $(venv-activate-script) |
| 78 | @echo |
| 79 | @echo "** -----------------------------------------------------------------------" |
| 80 | @echo "** python pylint syntax checking" |
| 81 | @echo "** -----------------------------------------------------------------------" |
| 82 | $(activate) && pip install --upgrade pylint |
| 83 | $(activate) && pylint --version |
| 84 | @echo |
| 85 | |
| 86 | ## ----------------------------------------------------------------------- |
| 87 | ## Intent: Display command usage |
| 88 | ## ----------------------------------------------------------------------- |
| 89 | help:: |
| 90 | @echo ' lint-pylint Syntax check python using the pylint command' |
| 91 | ifdef VERBOSE |
| 92 | @echo ' $(MAKE) lint-pylint PYTHON_FILES=...' |
| 93 | @echo ' lint-pylint-modified pylint checking: only modified' |
| 94 | @echo ' lint-pylint-all pylint checking: exhaustive' |
| 95 | @echo ' lint-pylint-install Install the pylint command' |
| 96 | endif |
| 97 | |
| 98 | $(if $(DEBUG),$(warning LEAVE)) |
| 99 | |
| 100 | # [EOF] |