blob: e83c2c10b06e8562eb3b4dbf439537a05f8f674e [file] [log] [blame]
Joey Armstrong825114e2023-09-08 15:18:51 -04001# -*- makefile -*-
2# -----------------------------------------------------------------------
Joey Armstrongdc04c932024-04-01 12:14:21 -04003# Copyright 2017-2024 Open Networking Foundation Contributors
Joey Armstrong825114e2023-09-08 15:18:51 -04004#
Joey Armstrongdc04c932024-04-01 12:14:21 -04005# Licensed under the Apache License, Version 2.0 (the "License");
Joey Armstrong825114e2023-09-08 15:18:51 -04006# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
Joey Armstrongdc04c932024-04-01 12:14:21 -04009# http:#www.apache.org/licenses/LICENSE-2.0
Joey Armstrong825114e2023-09-08 15:18:51 -040010#
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 Armstrongdc04c932024-04-01 12:14:21 -040017# SPDX-FileCopyrightText: 2017-2024 Open Networking Foundation Contributors
18# SPDX-License-Identifier: Apache-2.0
19# -----------------------------------------------------------------------
20# Intent:
21# -----------------------------------------------------------------------
Joey Armstrong825114e2023-09-08 15:18:51 -040022
23$(if $(DEBUG),$(warning ENTER))
24
25##-------------------##
26##---] GLOBALS [---##
27##-------------------##
28.PHONY: lint-pylint lint-pylint-all lint-pylint-modified
29
30PYTHON_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## -----------------------------------------------------------------------
40ifndef 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)
44endif# 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))
57lint-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## -----------------------------------------------------------------------
68lint-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
77lint-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## -----------------------------------------------------------------------
89help::
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]