blob: a2406d4f1a5b08e80712f843fce382ed6d0067ed [file] [log] [blame]
Joey Armstrong0205d332023-04-11 17:29:23 -04001# -*- 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# -----------------------------------------------------------------------
Joey Armstrong686d3b92023-09-15 17:59:59 -040017# https://gerrit.opencord.org/plugins/gitiles/onf-make
18# ONF.makefiles.lint.groovy.version = 1.1.1 (+local edits)
19# -----------------------------------------------------------------------
Joey Armstrong0205d332023-04-11 17:29:23 -040020
21##-------------------##
22##---] GLOBALS [---##
23##-------------------##
24
25groovy-check := npm-groovy-lint
26
27groovy-check-args := $(null)
28# groovy-check-args += --loglevel info
29# groovy-check-args += --ignorepattern
30# groovy-check-args += --verbose
31
32##-------------------##
33##---] TARGETS [---##
34##-------------------##
Joey Armstrong686d3b92023-09-15 17:59:59 -040035
36## -----------------------------------------------------------------------
37## Intent: Enabled by repository_sandbox_root/config.mk
38## -----------------------------------------------------------------------
Joey Armstrong0205d332023-04-11 17:29:23 -040039ifndef NO-LINT-GROOVY
40 lint : lint-groovy
41endif
42
43## -----------------------------------------------------------------------
Joey Armstrongf548adc2023-09-08 15:59:42 -040044## All or on-demand
45## make lint-groovy BY_SRC="a/b/c.groovy d/e/f.groovy"
46## -----------------------------------------------------------------------
Joey Armstrong686d3b92023-09-15 17:59:59 -040047ifdef GROOVY_SRC
Joey Armstrongf548adc2023-09-08 15:59:42 -040048 lint-groovy : lint-groovy-src
49else
50 lint-groovy : lint-groovy-all
51endif
52
53## -----------------------------------------------------------------------
Joey Armstrong0205d332023-04-11 17:29:23 -040054## Intent: Perform a lint check on command line script sources
55## -----------------------------------------------------------------------
Joey Armstrongf548adc2023-09-08 15:59:42 -040056lint-groovy-all:
Joey Armstrong88fca722024-01-31 22:52:17 -050057
58 $(call banner-enter,Target $@)
59
Joey Armstrong0205d332023-04-11 17:29:23 -040060 $(groovy-check) --version
61 @echo
62 $(HIDE)$(env-clean) find . -iname '*.groovy' -print0 \
63 | $(xargs-n1) $(groovy-check) $(groovy-check-args)
64
Joey Armstrong88fca722024-01-31 22:52:17 -050065 $(call banner-leave,Target $@)
66
Joey Armstrong0205d332023-04-11 17:29:23 -040067## -----------------------------------------------------------------------
Joey Armstrong686d3b92023-09-15 17:59:59 -040068## Intent: On-demand lint checking
Joey Armstrongf548adc2023-09-08 15:59:42 -040069## -----------------------------------------------------------------------
Joey Armstrongf548adc2023-09-08 15:59:42 -040070lint-groovy-src:
Joey Armstrong686d3b92023-09-15 17:59:59 -040071 ifndef GROOVY_SRC
72 @echo "ERROR: Usage: $(MAKE) $@ GROOVY_SRC="
73 @exit 1
74 endif
Joey Armstrongf548adc2023-09-08 15:59:42 -040075 $(groovy-check) --version
76 @echo
Joey Armstrong686d3b92023-09-15 17:59:59 -040077 $(HIDE) $(groovy-check) $(groovy-check-args) $(GROOVY_SRC)
Joey Armstrongf548adc2023-09-08 15:59:42 -040078
79## -----------------------------------------------------------------------
Joey Armstrong88fca722024-01-31 22:52:17 -050080## Intent: Perform lint check on locally modified sources
Joey Armstrongf548adc2023-09-08 15:59:42 -040081## -----------------------------------------------------------------------
Joey Armstrong686d3b92023-09-15 17:59:59 -040082# lint-groovy-bygit = $(shell git diff --name-only HEAD | grep '\.groovy')
83lint-groovy-bygit = $(git status -s | grep '\.sh' | grep -v -e '^D' -e '^?' | cut -c4-)
Joey Armstrongf548adc2023-09-08 15:59:42 -040084lint-groovy-mod:
85 $(groovy-check) --version
86 @echo
Joey Armstrong686d3b92023-09-15 17:59:59 -040087 $(foreach fyl,$(lint-groovy-bygit),$(groovy-check) $(groovy-check-args) $(fyl))
Joey Armstrongf548adc2023-09-08 15:59:42 -040088
89## -----------------------------------------------------------------------
Joey Armstrong0205d332023-04-11 17:29:23 -040090## Intent: Display command help
91## -----------------------------------------------------------------------
92help-summary ::
Joey Armstrongf548adc2023-09-08 15:59:42 -040093 @echo ' lint-groovy Conditionally lint groovy source'
Joey Armstrongf548adc2023-09-08 15:59:42 -040094 ifdef VERBOSE
Joey Armstrong686d3b92023-09-15 17:59:59 -040095 @echo ' lint-groovy-all Lint all available sources'
96 @echo ' lint-groovy-mod Lint locally modified (git status)'
97 @echo ' lint-groovy-src Lint individually (BY_SRC=list-of-files)'
Joey Armstrongf548adc2023-09-08 15:59:42 -040098 endif
Joey Armstrong686d3b92023-09-15 17:59:59 -040099
Joey Armstrong0205d332023-04-11 17:29:23 -0400100# [EOF]