blob: ed0df2c4c5f548d9b8886c5678781469ee731301 [file] [log] [blame]
Joey Armstrongf548adc2023-09-08 15:59:42 -04001# -*- makefile -*-
2# -----------------------------------------------------------------------
Joey Armstrongdc04c932024-04-01 12:14:21 -04003# Copyright 2017-2024 Open Networking Foundation Contributors
Joey Armstrongf548adc2023-09-08 15:59:42 -04004#
Joey Armstrongdc04c932024-04-01 12:14:21 -04005# Licensed under the Apache License, Version 2.0 (the "License");
Joey Armstrongf548adc2023-09-08 15:59:42 -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 Armstrongf548adc2023-09-08 15:59:42 -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 Armstrongf548adc2023-09-08 15:59:42 -040022
23$(if $(DEBUG),$(warning ENTER))
24
25##-------------------##
26##---] GLOBALS [---##
27##-------------------##
28.PHONY: lint-yaml lint-yaml-all lint-yaml-modified
29
30have-yaml-files := $(if $(strip $(YAML_FILES)),true)
31YAML_FILES ?= $(error YAML_FILES= is required)
32
33YAMLLINT = $(activate) && yamllint
34yamllint-args += --strict
35
36## -----------------------------------------------------------------------
37## Intent: Use the yaml command to perform syntax checking.
38## -----------------------------------------------------------------------
39ifndef NO-LINT-YAML
40 lint-yaml-mode := $(if $(have-yaml-files),modified,all)
41 lint : lint-yaml
42 lint-yaml : lint-yaml-$(lint-yaml-mode)
43endif# NO-LINT-YAML
44
45## -----------------------------------------------------------------------
46## Intent: exhaustive yaml syntax checking
47## -----------------------------------------------------------------------
48lint-yaml-all: lint-yaml-cmd-version
49
50 $(call banner-enter,Target $@)
51 $(HIDE)$(MAKE) --no-print-directory lint-yaml-install
52 $(HIDE)$(activate) && $(call gen-yaml-find-cmd) \
53 | $(env-clean) $(xargs-cmd) -I'{}' \
54 bash -c "$(YAMLLINT) $(yamllint-args) {}"
55 $(call banner-leave,Target $@)
56
57## -----------------------------------------------------------------------
58## Intent: check deps for format and python3 cleanliness
59## Note:
60## yaml --py3k option no longer supported
61## -----------------------------------------------------------------------
62lint-yaml-modified: lint-yaml-cmd-version
63
64 $(call banner-enter,Target $@)
65 $(HIDE)$(MAKE) --no-print-directory lint-yaml-install
66 $(YAMLLINT) $(yamllint-args) $(YAML_FILES)
67 $(call banner-leave,Target $@)
68
69## -----------------------------------------------------------------------
70## Intent: Display command usage
71## -----------------------------------------------------------------------
72help::
73 @echo ' lint-yaml Syntax check python using the yaml command'
74 ifdef VERBOSE
75 @echo ' $(MAKE) lint-yaml YAML_FILES=...'
76 @echo ' lint-yaml-all yaml checking: exhaustive'
77 @echo ' lint-yaml-modified yaml checking: only locally modified'
78 @echo ' lint-yaml-install Install the pylint command'
79 endif
80
81$(if $(DEBUG),$(warning LEAVE))
82
83# [EOF]