Joey Armstrong | 36592e3 | 2022-11-28 09:00:28 -0500 | [diff] [blame] | 1 | # -*- makefile -*- |
| 2 | # ----------------------------------------------------------------------- |
Joey Armstrong | 4de98b7 | 2023-02-09 14:51:38 -0500 | [diff] [blame] | 3 | # Copyright 2017-2023 Open Networking Foundation (ONF) and the ONF Contributors |
Joey Armstrong | 36592e3 | 2022-11-28 09:00:28 -0500 | [diff] [blame] | 4 | # |
Joey Armstrong | 4de98b7 | 2023-02-09 14:51:38 -0500 | [diff] [blame] | 5 | # Licensed under the Apache License, Version 2.0 (the "License") |
Joey Armstrong | 36592e3 | 2022-11-28 09:00:28 -0500 | [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 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 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 | # ----------------------------------------------------------------------- |
| 17 | |
Joey Armstrong | 4de98b7 | 2023-02-09 14:51:38 -0500 | [diff] [blame] | 18 | $(if $(DEBUG),$(warning ENTER)) |
Joey Armstrong | 36592e3 | 2022-11-28 09:00:28 -0500 | [diff] [blame] | 19 | |
Joey Armstrong | 4de98b7 | 2023-02-09 14:51:38 -0500 | [diff] [blame] | 20 | ##-------------------## |
| 21 | ##---] GLOBALS [---## |
| 22 | ##-------------------## |
| 23 | .PHONY: lint-yaml lint-yaml-all lint-yaml-modified |
Joey Armstrong | 36592e3 | 2022-11-28 09:00:28 -0500 | [diff] [blame] | 24 | |
Joey Armstrong | 4de98b7 | 2023-02-09 14:51:38 -0500 | [diff] [blame] | 25 | have-yaml-files := $(if $(strip $(YAML_FILES)),true) |
| 26 | YAML_FILES ?= $(error YAML_FILES= is required) |
Joey Armstrong | 36592e3 | 2022-11-28 09:00:28 -0500 | [diff] [blame] | 27 | |
Joey Armstrong | 4de98b7 | 2023-02-09 14:51:38 -0500 | [diff] [blame] | 28 | ## ----------------------------------------------------------------------- |
| 29 | ## Intent: Use the yaml command to perform syntax checking. |
| 30 | ## o If UNSTABLE=1 syntax check all sources |
| 31 | ## o else only check sources modified by the developer. |
| 32 | ## Usage: |
| 33 | ## % make lint UNSTABLE=1 |
| 34 | ## % make lint-yaml-all |
| 35 | ## ----------------------------------------------------------------------- |
| 36 | ifndef NO-LINT-YAML |
| 37 | lint-yaml-mode := $(if $(have-yaml-files),modified,all) |
| 38 | lint : lint-yaml-$(lint-yaml-mode) |
| 39 | endif# NO-LINT-YAML |
Joey Armstrong | 36592e3 | 2022-11-28 09:00:28 -0500 | [diff] [blame] | 40 | |
Joey Armstrong | 4de98b7 | 2023-02-09 14:51:38 -0500 | [diff] [blame] | 41 | ## ----------------------------------------------------------------------- |
| 42 | ## Intent: exhaustive yaml syntax checking |
| 43 | ## ----------------------------------------------------------------------- |
| 44 | lint-yaml-all: |
| 45 | $(HIDE)$(MAKE) --no-print-directory lint-yaml-install |
| 46 | |
| 47 | find . \( -iname '*.yaml' -o -iname '*.yml' \) -print0 \ |
| 48 | | $(xargs-n1-clean) yamllint --strict |
| 49 | |
| 50 | ## ----------------------------------------------------------------------- |
| 51 | ## Intent: check deps for format and python3 cleanliness |
| 52 | ## Note: |
| 53 | ## yaml --py3k option no longer supported |
| 54 | ## ----------------------------------------------------------------------- |
| 55 | lint-yaml-modified: |
| 56 | $(HIDE)$(MAKE) --no-print-directory lint-yaml-install |
| 57 | yamllint -s $(YAML_FILES) |
| 58 | |
| 59 | ## ----------------------------------------------------------------------- |
| 60 | ## Intent: |
| 61 | ## ----------------------------------------------------------------------- |
| 62 | lint-yaml-install: |
| 63 | @echo |
| 64 | @echo "** -----------------------------------------------------------------------" |
| 65 | @echo "** yaml syntax checking" |
| 66 | @echo "** -----------------------------------------------------------------------" |
| 67 | yamllint --version |
| 68 | @echo |
| 69 | |
| 70 | ## ----------------------------------------------------------------------- |
| 71 | ## Intent: Display command usage |
| 72 | ## ----------------------------------------------------------------------- |
Joey Armstrong | 36592e3 | 2022-11-28 09:00:28 -0500 | [diff] [blame] | 73 | help:: |
Joey Armstrong | 4de98b7 | 2023-02-09 14:51:38 -0500 | [diff] [blame] | 74 | @echo ' lint-yaml Syntax check python using the yaml command' |
| 75 | ifdef VERBOSE |
| 76 | @echo ' lint-yaml-all yaml checking: exhaustive' |
| 77 | @echo ' lint-yaml-modified yaml checking: only modified' |
| 78 | endif |
| 79 | |
| 80 | $(if $(DEBUG),$(warning LEAVE)) |
Joey Armstrong | 36592e3 | 2022-11-28 09:00:28 -0500 | [diff] [blame] | 81 | |
| 82 | # [EOF] |