blob: 2ed70e85c64f41ec4319f7bbc73d806f6c101a60 [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## -----------------------------------------------------------------------
Joey Armstrong825114e2023-09-08 15:18:51 -040049lint-pylint-all: $(venv-activate-script)
Joey Armstrongccab2cf2024-04-06 18:00:59 -040050
Joey Armstrong825114e2023-09-08 15:18:51 -040051 $(MAKE) --no-print-directory lint-pylint-install
52
53 $(activate) && $(call gen-python-find-cmd) | $(xargs-n1) pylint
Joey Armstrong825114e2023-09-08 15:18:51 -040054
55## -----------------------------------------------------------------------
56## Intent: check deps for format and python3 cleanliness
57## Note:
58## pylint --py3k option no longer supported
59## -----------------------------------------------------------------------
60lint-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
69lint-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## -----------------------------------------------------------------------
81help::
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]