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