blob: 819a1af1a171777d725db716bdfbf77dba6295ac [file] [log] [blame]
Joey Armstrongdd334492023-07-09 17:59:02 -04001# -*- makefile -*-
2# -----------------------------------------------------------------------
Joey Armstrong518f3572024-02-11 07:56:25 -05003# Copyright 2022-2024 Open Networking Foundation (ONF) and the ONF Contributors
Joey Armstrongdd334492023-07-09 17:59:02 -04004#
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#
Joey Armstrong518f3572024-02-11 07:56:25 -050017# SPDX-FileCopyrightText: 2024 Open Networking Foundation (ONF) and the ONF Contributors
Joey Armstrongdd334492023-07-09 17:59:02 -040018# 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
28YAMLLINT = $(activate) && yamllint
29
30## -------------------------------
31## Add requirement(s) for checking
32## -------------------------------
33yamllint-cfg := yamllint.helm
34yamllint-conf = $(wildcard $(yamllint-cfg) $(ONF_MAKEDIR)/lint/yaml/$(yamllint-cfg))
35yamllint-args += $(addprefix --config-file$(space),$(yamllint-conf))
36yamllint-args += --strict
37
38## -----------------------------------------------------------------------
39## Intent: Use the yaml command to perform syntax checking.
40## -----------------------------------------------------------------------
41ifndef 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)
46endif# NO-LINT-YAML
47
48## -----------------------------------------------------------------------
49## ----------------------------------------------------------------------
50lint-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## -----------------------------------------------------------------------
63help::
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]