Joey Armstrong | 0205d33 | 2023-04-11 17:29:23 -0400 | [diff] [blame] | 1 | # -*- makefile -*- |
| 2 | # ----------------------------------------------------------------------- |
Joey Armstrong | dc04c93 | 2024-04-01 12:14:21 -0400 | [diff] [blame] | 3 | # Copyright 2017-2024 Open Networking Foundation Contributors |
Joey Armstrong | 0205d33 | 2023-04-11 17:29:23 -0400 | [diff] [blame] | 4 | # |
Joey Armstrong | dc04c93 | 2024-04-01 12:14:21 -0400 | [diff] [blame] | 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
Joey Armstrong | 0205d33 | 2023-04-11 17:29:23 -0400 | [diff] [blame] | 6 | # you may not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
| 8 | # |
Joey Armstrong | dc04c93 | 2024-04-01 12:14:21 -0400 | [diff] [blame] | 9 | # http:#www.apache.org/licenses/LICENSE-2.0 |
Joey Armstrong | 0205d33 | 2023-04-11 17:29:23 -0400 | [diff] [blame] | 10 | # |
| 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 Armstrong | dc04c93 | 2024-04-01 12:14:21 -0400 | [diff] [blame] | 17 | # SPDX-FileCopyrightText: 2017-2024 Open Networking Foundation Contributors |
| 18 | # SPDX-License-Identifier: Apache-2.0 |
| 19 | # ----------------------------------------------------------------------- |
| 20 | # Intent: |
| 21 | # ----------------------------------------------------------------------- |
Joey Armstrong | 0205d33 | 2023-04-11 17:29:23 -0400 | [diff] [blame] | 22 | |
| 23 | $(if $(DEBUG),$(warning ENTER)) |
| 24 | |
| 25 | ##-------------------## |
| 26 | ##---] GLOBALS [---## |
| 27 | ##-------------------## |
| 28 | .PHONY: lint-yaml lint-yaml-all lint-yaml-modified |
| 29 | |
| 30 | have-yaml-files := $(if $(strip $(YAML_FILES)),true) |
| 31 | YAML_FILES ?= $(error YAML_FILES= is required) |
| 32 | |
Joey Armstrong | ccab2cf | 2024-04-06 18:00:59 -0400 | [diff] [blame] | 33 | # Gather sources to check |
| 34 | yaml-find-args := find . |
| 35 | yaml-find-args += $(foreach dir,$(onf-excl-dirs),-not -path './$(dir)/*') |
| 36 | |
Joey Armstrong | 0205d33 | 2023-04-11 17:29:23 -0400 | [diff] [blame] | 37 | ## ----------------------------------------------------------------------- |
| 38 | ## Intent: Use the yaml command to perform syntax checking. |
| 39 | ## o If UNSTABLE=1 syntax check all sources |
| 40 | ## o else only check sources modified by the developer. |
| 41 | ## Usage: |
| 42 | ## % make lint UNSTABLE=1 |
| 43 | ## % make lint-yaml-all |
| 44 | ## ----------------------------------------------------------------------- |
| 45 | lint-yaml-mode := $(if $(have-yaml-files),modified,all) |
| 46 | lint-yaml : lint-yaml-$(lint-yaml-mode) |
| 47 | |
| 48 | ifndef NO-LINT-YAML |
| 49 | lint : lint-yaml# # Enable as a default lint target |
| 50 | endif# NO-LINT-YAML |
| 51 | |
| 52 | ## ----------------------------------------------------------------------- |
| 53 | ## Intent: exhaustive yaml syntax checking |
| 54 | ## ----------------------------------------------------------------------- |
| 55 | lint-yaml-all: |
| 56 | $(HIDE)$(MAKE) --no-print-directory lint-yaml-install |
| 57 | |
Joey Armstrong | ccab2cf | 2024-04-06 18:00:59 -0400 | [diff] [blame] | 58 | find . $(yaml-find-args) \( -iname '*.yaml' -o -iname '*.yml' \) -print0 \ |
Joey Armstrong | 0205d33 | 2023-04-11 17:29:23 -0400 | [diff] [blame] | 59 | | $(xargs-n1-clean) yamllint --strict |
| 60 | |
| 61 | ## ----------------------------------------------------------------------- |
| 62 | ## Intent: check deps for format and python3 cleanliness |
| 63 | ## Note: |
| 64 | ## yaml --py3k option no longer supported |
| 65 | ## ----------------------------------------------------------------------- |
| 66 | lint-yaml-modified: |
| 67 | $(HIDE)$(MAKE) --no-print-directory lint-yaml-install |
| 68 | yamllint -s $(YAML_FILES) |
| 69 | |
| 70 | ## ----------------------------------------------------------------------- |
| 71 | ## Intent: |
| 72 | ## ----------------------------------------------------------------------- |
| 73 | lint-yaml-install: |
| 74 | @echo |
| 75 | @echo "** -----------------------------------------------------------------------" |
| 76 | @echo "** yaml syntax checking" |
| 77 | @echo "** -----------------------------------------------------------------------" |
| 78 | yamllint --version |
| 79 | @echo |
| 80 | |
| 81 | ## ----------------------------------------------------------------------- |
| 82 | ## Intent: Display command usage |
| 83 | ## ----------------------------------------------------------------------- |
| 84 | help:: |
| 85 | @echo ' lint-yaml Syntax check python using the yaml command' |
| 86 | ifdef VERBOSE |
| 87 | @echo ' lint-yaml-all yaml checking: exhaustive' |
| 88 | @echo ' lint-yaml-modified yaml checking: only locally modified' |
| 89 | endif |
| 90 | |
| 91 | $(if $(DEBUG),$(warning LEAVE)) |
| 92 | |
| 93 | # [EOF] |