blob: 8caddd780992faac6a84bd78782beb5b9436fd49 [file] [log] [blame]
Joey Armstrong0205d332023-04-11 17:29:23 -04001# -*- makefile -*-
2# -----------------------------------------------------------------------
Joey Armstrongdc04c932024-04-01 12:14:21 -04003# Copyright 2022-2024 Open Networking Foundation Contributors
Joey Armstrong0205d332023-04-11 17:29:23 -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#
Joey Armstrongdc04c932024-04-01 12:14:21 -04009# http:#www.apache.org/licenses/LICENSE-2.0
Joey Armstrong0205d332023-04-11 17:29:23 -040010#
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 Armstrongdc04c932024-04-01 12:14:21 -040017# SPDX-FileCopyrightText: 2022-2024 Open Networking Foundation Contributors
18# SPDX-License-Identifier: Apache-2.0
19# -----------------------------------------------------------------------
20# Intent:
21# -----------------------------------------------------------------------
Joey Armstrong0205d332023-04-11 17:29:23 -040022
23##-------------------##
24##---] GLOBALS [---##
25##-------------------##
26
27groovy-check := npm-groovy-lint
28
Joey Armstronga3f9aca2024-02-11 11:58:11 -050029groovy-check-conf := $(call path-by-makefile,.groovylintrc.json)
30
Joey Armstrong0205d332023-04-11 17:29:23 -040031groovy-check-args := $(null)
Joey Armstronga3f9aca2024-02-11 11:58:11 -050032groovy-check-args += --config "$(groovy-check-conf)"
33
Joey Armstrong0205d332023-04-11 17:29:23 -040034# groovy-check-args += --loglevel info
35# groovy-check-args += --ignorepattern
36# groovy-check-args += --verbose
37
38##-------------------##
39##---] TARGETS [---##
40##-------------------##
Joey Armstrong686d3b92023-09-15 17:59:59 -040041
42## -----------------------------------------------------------------------
43## Intent: Enabled by repository_sandbox_root/config.mk
44## -----------------------------------------------------------------------
Joey Armstrong0205d332023-04-11 17:29:23 -040045ifndef NO-LINT-GROOVY
46 lint : lint-groovy
47endif
48
49## -----------------------------------------------------------------------
Joey Armstrongf548adc2023-09-08 15:59:42 -040050## All or on-demand
51## make lint-groovy BY_SRC="a/b/c.groovy d/e/f.groovy"
52## -----------------------------------------------------------------------
Joey Armstrong686d3b92023-09-15 17:59:59 -040053ifdef GROOVY_SRC
Joey Armstrongf548adc2023-09-08 15:59:42 -040054 lint-groovy : lint-groovy-src
55else
56 lint-groovy : lint-groovy-all
57endif
58
59## -----------------------------------------------------------------------
Joey Armstrong0205d332023-04-11 17:29:23 -040060## Intent: Perform a lint check on command line script sources
61## -----------------------------------------------------------------------
Joey Armstrongf548adc2023-09-08 15:59:42 -040062lint-groovy-all:
Joey Armstrong88fca722024-01-31 22:52:17 -050063
64 $(call banner-enter,Target $@)
65
Joey Armstrong0205d332023-04-11 17:29:23 -040066 $(groovy-check) --version
67 @echo
68 $(HIDE)$(env-clean) find . -iname '*.groovy' -print0 \
69 | $(xargs-n1) $(groovy-check) $(groovy-check-args)
70
Joey Armstrong88fca722024-01-31 22:52:17 -050071 $(call banner-leave,Target $@)
72
Joey Armstrong0205d332023-04-11 17:29:23 -040073## -----------------------------------------------------------------------
Joey Armstrong686d3b92023-09-15 17:59:59 -040074## Intent: On-demand lint checking
Joey Armstrongf548adc2023-09-08 15:59:42 -040075## -----------------------------------------------------------------------
Joey Armstrongf548adc2023-09-08 15:59:42 -040076lint-groovy-src:
Joey Armstrong686d3b92023-09-15 17:59:59 -040077 ifndef GROOVY_SRC
78 @echo "ERROR: Usage: $(MAKE) $@ GROOVY_SRC="
79 @exit 1
80 endif
Joey Armstrongf548adc2023-09-08 15:59:42 -040081 $(groovy-check) --version
82 @echo
Joey Armstrong686d3b92023-09-15 17:59:59 -040083 $(HIDE) $(groovy-check) $(groovy-check-args) $(GROOVY_SRC)
Joey Armstrongf548adc2023-09-08 15:59:42 -040084
85## -----------------------------------------------------------------------
Joey Armstrong88fca722024-01-31 22:52:17 -050086## Intent: Perform lint check on locally modified sources
Joey Armstrongf548adc2023-09-08 15:59:42 -040087## -----------------------------------------------------------------------
Joey Armstrong686d3b92023-09-15 17:59:59 -040088# lint-groovy-bygit = $(shell git diff --name-only HEAD | grep '\.groovy')
89lint-groovy-bygit = $(git status -s | grep '\.sh' | grep -v -e '^D' -e '^?' | cut -c4-)
Joey Armstrongf548adc2023-09-08 15:59:42 -040090lint-groovy-mod:
91 $(groovy-check) --version
92 @echo
Joey Armstrong686d3b92023-09-15 17:59:59 -040093 $(foreach fyl,$(lint-groovy-bygit),$(groovy-check) $(groovy-check-args) $(fyl))
Joey Armstrongf548adc2023-09-08 15:59:42 -040094
95## -----------------------------------------------------------------------
Joey Armstrong0205d332023-04-11 17:29:23 -040096## Intent: Display command help
97## -----------------------------------------------------------------------
98help-summary ::
Joey Armstrongf548adc2023-09-08 15:59:42 -040099 @echo ' lint-groovy Conditionally lint groovy source'
Joey Armstrongf548adc2023-09-08 15:59:42 -0400100 ifdef VERBOSE
Joey Armstrong686d3b92023-09-15 17:59:59 -0400101 @echo ' lint-groovy-all Lint all available sources'
102 @echo ' lint-groovy-mod Lint locally modified (git status)'
103 @echo ' lint-groovy-src Lint individually (BY_SRC=list-of-files)'
Joey Armstrongf548adc2023-09-08 15:59:42 -0400104 endif
Joey Armstrong686d3b92023-09-15 17:59:59 -0400105
Joey Armstrong0205d332023-04-11 17:29:23 -0400106# [EOF]