blob: c297d94456ddd537b1443622b7e82fec0f26ac26 [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-flake8 lint-flake8-all lint-flake8-modified
29
30PYTHON_FILES ?= $(error PYTHON_FILES= required)
31
32## -----------------------------------------------------------------------
33## Intent: Use the flake8 command to perform syntax checking.
34## Usage:
35## % make lint
36## % make lint-flake8-all
37## -----------------------------------------------------------------------
38ifndef NO-LINT-FLAKE8
39 lint-flake8-mode := $(if $(have-python-files),modified,all)
40 lint : lint-flake8
41 lint-flake8 : lint-flake8-$(lint-flake8-mode)
42endif# NO-LINT-FLAKE8
43
44## -----------------------------------------------------------------------
45## Intent: exhaustive flake8 syntax checking
46## -----------------------------------------------------------------------
47# Construct: find . \( -name '__ignored__' -o -name dir -o name dir \)
48# flake8-find-filter := $(null)
49# flake8-find-filter += -name '__ignored__'# # for alignment
50# flake8-find-filter += $(foreach dir,$(onf-excl-dirs),-o -name $(dir)))
51
52lint-flake8-all: $(venv-activate-script)
53 $(HIDE)$(MAKE) --no-print-directory lint-flake8-install
54
55 $(activate) && $(call gen-python-find-cmd) \
56 | $(xargs-n1) flake8 --max-line-length=99 --count
57
Joey Armstrong825114e2023-09-08 15:18:51 -040058## -----------------------------------------------------------------------
59## Intent: check deps for format and python3 cleanliness
60## Note:
61## pylint --py3k option no longer supported
62## -----------------------------------------------------------------------
63lint-flake8-modified: $(venv-activate-script)
64 $(HIDE)$(MAKE) --no-print-directory lint-flake8-install
65
66 $(activate)\
67 && flake8 --max-line-length=99 --count $(PYTHON_FILES)
68
69## -----------------------------------------------------------------------
70## Intent:
71## -----------------------------------------------------------------------
72.PHONY: lint-flake8-install
73lint-flake8-install: $(venv-activate-script)
74 @echo
75 @echo "** -----------------------------------------------------------------------"
76 @echo "** python flake8 syntax checking"
77 @echo "** -----------------------------------------------------------------------"
78 $(activate) && pip install --upgrade flake8
79 $(activate) && flake8 --version
80 @echo
81
82## -----------------------------------------------------------------------
83## Intent: Display command usage
84## -----------------------------------------------------------------------
85help::
86 @echo ' lint-flake8 Syntax check python using the flake8 command'
87 ifdef VERBOSE
88 @echo ' $(MAKE) lint-pylint PYTHON_FILES=...'
89 @echo ' lint-flake8-modified flake8 checking: only modified'
90 @echo ' lint-flake8-all flake8 checking: exhaustive'
91 @echo ' lint-flake8-install Install the flake8 command'
92 endif
93
94$(if $(DEBUG),$(warning LEAVE))
95
96# [EOF]