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