blob: 9cc80c3dc0e12274c8c5a5076e5d15813717962f [file] [log] [blame]
Joey Armstrong0205d332023-04-11 17:29:23 -04001# -*- makefile -*-
2# -----------------------------------------------------------------------
Joey Armstronga3f9aca2024-02-11 11:58:11 -05003# Copyright 2022-2024 Open Networking Foundation (ONF) and the ONF 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#
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
18##-------------------##
19##---] GLOBALS [---##
20##-------------------##
21
22groovy-check := npm-groovy-lint
23
Joey Armstronga3f9aca2024-02-11 11:58:11 -050024groovy-check-conf := $(call path-by-makefile,.groovylintrc.json)
25
Joey Armstrong0205d332023-04-11 17:29:23 -040026groovy-check-args := $(null)
Joey Armstronga3f9aca2024-02-11 11:58:11 -050027groovy-check-args += --config "$(groovy-check-conf)"
28
Joey Armstrong0205d332023-04-11 17:29:23 -040029# groovy-check-args += --loglevel info
30# groovy-check-args += --ignorepattern
31# groovy-check-args += --verbose
32
33##-------------------##
34##---] TARGETS [---##
35##-------------------##
Joey Armstrong686d3b92023-09-15 17:59:59 -040036
37## -----------------------------------------------------------------------
38## Intent: Enabled by repository_sandbox_root/config.mk
39## -----------------------------------------------------------------------
Joey Armstrong0205d332023-04-11 17:29:23 -040040ifndef NO-LINT-GROOVY
41 lint : lint-groovy
42endif
43
44## -----------------------------------------------------------------------
Joey Armstrongf548adc2023-09-08 15:59:42 -040045## All or on-demand
46## make lint-groovy BY_SRC="a/b/c.groovy d/e/f.groovy"
47## -----------------------------------------------------------------------
Joey Armstrong686d3b92023-09-15 17:59:59 -040048ifdef GROOVY_SRC
Joey Armstrongf548adc2023-09-08 15:59:42 -040049 lint-groovy : lint-groovy-src
50else
51 lint-groovy : lint-groovy-all
52endif
53
54## -----------------------------------------------------------------------
Joey Armstrong0205d332023-04-11 17:29:23 -040055## Intent: Perform a lint check on command line script sources
56## -----------------------------------------------------------------------
Joey Armstrongf548adc2023-09-08 15:59:42 -040057lint-groovy-all:
Joey Armstrong88fca722024-01-31 22:52:17 -050058
59 $(call banner-enter,Target $@)
60
Joey Armstrong0205d332023-04-11 17:29:23 -040061 $(groovy-check) --version
62 @echo
63 $(HIDE)$(env-clean) find . -iname '*.groovy' -print0 \
64 | $(xargs-n1) $(groovy-check) $(groovy-check-args)
65
Joey Armstrong88fca722024-01-31 22:52:17 -050066 $(call banner-leave,Target $@)
67
Joey Armstrong0205d332023-04-11 17:29:23 -040068## -----------------------------------------------------------------------
Joey Armstrong686d3b92023-09-15 17:59:59 -040069## Intent: On-demand lint checking
Joey Armstrongf548adc2023-09-08 15:59:42 -040070## -----------------------------------------------------------------------
Joey Armstrongf548adc2023-09-08 15:59:42 -040071lint-groovy-src:
Joey Armstrong686d3b92023-09-15 17:59:59 -040072 ifndef GROOVY_SRC
73 @echo "ERROR: Usage: $(MAKE) $@ GROOVY_SRC="
74 @exit 1
75 endif
Joey Armstrongf548adc2023-09-08 15:59:42 -040076 $(groovy-check) --version
77 @echo
Joey Armstrong686d3b92023-09-15 17:59:59 -040078 $(HIDE) $(groovy-check) $(groovy-check-args) $(GROOVY_SRC)
Joey Armstrongf548adc2023-09-08 15:59:42 -040079
80## -----------------------------------------------------------------------
Joey Armstrong88fca722024-01-31 22:52:17 -050081## Intent: Perform lint check on locally modified sources
Joey Armstrongf548adc2023-09-08 15:59:42 -040082## -----------------------------------------------------------------------
Joey Armstrong686d3b92023-09-15 17:59:59 -040083# lint-groovy-bygit = $(shell git diff --name-only HEAD | grep '\.groovy')
84lint-groovy-bygit = $(git status -s | grep '\.sh' | grep -v -e '^D' -e '^?' | cut -c4-)
Joey Armstrongf548adc2023-09-08 15:59:42 -040085lint-groovy-mod:
86 $(groovy-check) --version
87 @echo
Joey Armstrong686d3b92023-09-15 17:59:59 -040088 $(foreach fyl,$(lint-groovy-bygit),$(groovy-check) $(groovy-check-args) $(fyl))
Joey Armstrongf548adc2023-09-08 15:59:42 -040089
90## -----------------------------------------------------------------------
Joey Armstrong0205d332023-04-11 17:29:23 -040091## Intent: Display command help
92## -----------------------------------------------------------------------
93help-summary ::
Joey Armstrongf548adc2023-09-08 15:59:42 -040094 @echo ' lint-groovy Conditionally lint groovy source'
Joey Armstrongf548adc2023-09-08 15:59:42 -040095 ifdef VERBOSE
Joey Armstrong686d3b92023-09-15 17:59:59 -040096 @echo ' lint-groovy-all Lint all available sources'
97 @echo ' lint-groovy-mod Lint locally modified (git status)'
98 @echo ' lint-groovy-src Lint individually (BY_SRC=list-of-files)'
Joey Armstrongf548adc2023-09-08 15:59:42 -040099 endif
Joey Armstrong686d3b92023-09-15 17:59:59 -0400100
Joey Armstrong0205d332023-04-11 17:29:23 -0400101# [EOF]