blob: 73f1c2970df053f096ec96a20b967ebe8fbc28c4 [file] [log] [blame]
Joey Armstrong0205d332023-04-11 17:29:23 -04001# -*- makefile -*-
2# -----------------------------------------------------------------------
Joey Armstrongdc04c932024-04-01 12:14:21 -04003# Copyright 2017-2024 Open Networking Foundation Contributors
Joey Armstrong0205d332023-04-11 17:29:23 -04004#
Joey Armstrongdc04c932024-04-01 12:14:21 -04005# Licensed under the Apache License, Version 2.0 (the "License");
Joey Armstrong0205d332023-04-11 17:29:23 -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 Armstrong0205d332023-04-11 17:29:23 -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 Armstrong0205d332023-04-11 17:29:23 -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
33## -----------------------------------------------------------------------
34## Intent: Use the yaml command to perform syntax checking.
35## o If UNSTABLE=1 syntax check all sources
36## o else only check sources modified by the developer.
37## Usage:
38## % make lint UNSTABLE=1
39## % make lint-yaml-all
40## -----------------------------------------------------------------------
41lint-yaml-mode := $(if $(have-yaml-files),modified,all)
42lint-yaml : lint-yaml-$(lint-yaml-mode)
43
44ifndef NO-LINT-YAML
45 lint : lint-yaml# # Enable as a default lint target
46endif# NO-LINT-YAML
47
48## -----------------------------------------------------------------------
49## Intent: exhaustive yaml syntax checking
50## -----------------------------------------------------------------------
51lint-yaml-all:
52 $(HIDE)$(MAKE) --no-print-directory lint-yaml-install
53
54 find . \( -iname '*.yaml' -o -iname '*.yml' \) -print0 \
55 | $(xargs-n1-clean) yamllint --strict
56
57## -----------------------------------------------------------------------
58## Intent: check deps for format and python3 cleanliness
59## Note:
60## yaml --py3k option no longer supported
61## -----------------------------------------------------------------------
62lint-yaml-modified:
63 $(HIDE)$(MAKE) --no-print-directory lint-yaml-install
64 yamllint -s $(YAML_FILES)
65
66## -----------------------------------------------------------------------
67## Intent:
68## -----------------------------------------------------------------------
69lint-yaml-install:
70 @echo
71 @echo "** -----------------------------------------------------------------------"
72 @echo "** yaml syntax checking"
73 @echo "** -----------------------------------------------------------------------"
74 yamllint --version
75 @echo
76
77## -----------------------------------------------------------------------
78## Intent: Display command usage
79## -----------------------------------------------------------------------
80help::
81 @echo ' lint-yaml Syntax check python using the yaml command'
82 ifdef VERBOSE
83 @echo ' lint-yaml-all yaml checking: exhaustive'
84 @echo ' lint-yaml-modified yaml checking: only locally modified'
85 endif
86
87$(if $(DEBUG),$(warning LEAVE))
88
89# [EOF]