Joey Armstrong | dd33449 | 2023-07-09 17:59:02 -0400 | [diff] [blame] | 1 | # -*- makefile -*- |
| 2 | # ----------------------------------------------------------------------- |
| 3 | # Copyright 2022-2023 Open Networking Foundation (ONF) and the ONF Contributors |
| 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 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 | # SPDX-FileCopyrightText: 2022 Open Networking Foundation (ONF) and the ONF Contributors |
| 18 | # SPDX-License-Identifier: Apache-2.0 |
| 19 | # ----------------------------------------------------------------------- |
| 20 | |
| 21 | $(if $(DEBUG),$(warning ENTER)) |
| 22 | |
| 23 | --onf-mk-lint-yaml-- := true# # Inhibit loading downstream lint-yaml targets |
| 24 | |
| 25 | # yamllint := $(env-clean) yamllint |
| 26 | # yamllint := $(activate) && yamllint |
| 27 | |
| 28 | YAMLLINT = $(activate) && yamllint |
| 29 | |
| 30 | ## ------------------------------- |
| 31 | ## Add requirement(s) for checking |
| 32 | ## ------------------------------- |
| 33 | yamllint-cfg := yamllint.helm |
| 34 | yamllint-conf = $(wildcard $(yamllint-cfg) $(ONF_MAKEDIR)/lint/yaml/$(yamllint-cfg)) |
| 35 | yamllint-args += $(addprefix --config-file$(space),$(yamllint-conf)) |
| 36 | yamllint-args += --strict |
| 37 | |
| 38 | ## ----------------------------------------------------------------------- |
| 39 | ## Intent: Use the yaml command to perform syntax checking. |
| 40 | ## ----------------------------------------------------------------------- |
| 41 | ifndef NO-LINT-YAML |
| 42 | # lint-yaml-mode := $(if $(have-yaml-files),modified,all) |
| 43 | lint : lint-yaml |
| 44 | lint-yaml : lint-yaml-votlha-lib-go |
| 45 | # lint-yaml : lint-yaml-all-votlha-lib-go-$(lint-yaml-mode) |
| 46 | endif# NO-LINT-YAML |
| 47 | |
| 48 | ## ----------------------------------------------------------------------- |
| 49 | ## ---------------------------------------------------------------------- |
| 50 | lint-yaml-votlha-lib-go: lint-yaml-cmd-version |
| 51 | |
| 52 | $(call banner-enter,Target $@) |
| 53 | $(HIDE)$(MAKE) --no-print-directory lint-yaml-install |
| 54 | |
| 55 | $(HIDE)$(env-clean) $(call gen-yaml-find-cmd) \ |
| 56 | | $(env-clean) $(xargs-cmd) -I'{}' \ |
| 57 | bash -c "$(YAMLLINT) $(yamllint-args) {}" |
| 58 | $(call banner-leave,Target $@) |
| 59 | |
| 60 | ## ----------------------------------------------------------------------- |
| 61 | ## Intent: Display command usage |
| 62 | ## ----------------------------------------------------------------------- |
| 63 | help:: |
| 64 | # lint-yaml help already displayed by lint/yaml/help.mk |
| 65 | ifdef VERBOSE |
| 66 | @echo ' $(MAKE) lint-yaml YAML_FILES=...' |
| 67 | @echo ' lint-yaml-votlha-lib-go lint-yaml for repo:voltha-lib-go' |
| 68 | endif |
| 69 | |
| 70 | $(if $(DEBUG),$(warning LEAVE)) |
| 71 | |
| 72 | # [EOF] |