blob: 5bea85379820e4317b7a9517a71fd4094393f42a [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 Armstrong0205d332023-04-11 17:29:23 -040057 $(groovy-check) --version
58 @echo
59 $(HIDE)$(env-clean) find . -iname '*.groovy' -print0 \
60 | $(xargs-n1) $(groovy-check) $(groovy-check-args)
61
62## -----------------------------------------------------------------------
Joey Armstrong686d3b92023-09-15 17:59:59 -040063## Intent: On-demand lint checking
Joey Armstrongf548adc2023-09-08 15:59:42 -040064## -----------------------------------------------------------------------
Joey Armstrongf548adc2023-09-08 15:59:42 -040065lint-groovy-src:
Joey Armstrong686d3b92023-09-15 17:59:59 -040066 ifndef GROOVY_SRC
67 @echo "ERROR: Usage: $(MAKE) $@ GROOVY_SRC="
68 @exit 1
69 endif
Joey Armstrongf548adc2023-09-08 15:59:42 -040070 $(groovy-check) --version
71 @echo
Joey Armstrong686d3b92023-09-15 17:59:59 -040072 $(HIDE) $(groovy-check) $(groovy-check-args) $(GROOVY_SRC)
Joey Armstrongf548adc2023-09-08 15:59:42 -040073
74## -----------------------------------------------------------------------
75## Intent: Perform lint check on a named list of files
76## -----------------------------------------------------------------------
Joey Armstrong686d3b92023-09-15 17:59:59 -040077# lint-groovy-bygit = $(shell git diff --name-only HEAD | grep '\.groovy')
78lint-groovy-bygit = $(git status -s | grep '\.sh' | grep -v -e '^D' -e '^?' | cut -c4-)
Joey Armstrongf548adc2023-09-08 15:59:42 -040079lint-groovy-mod:
80 $(groovy-check) --version
81 @echo
Joey Armstrong686d3b92023-09-15 17:59:59 -040082 $(foreach fyl,$(lint-groovy-bygit),$(groovy-check) $(groovy-check-args) $(fyl))
Joey Armstrongf548adc2023-09-08 15:59:42 -040083
84## -----------------------------------------------------------------------
Joey Armstrong0205d332023-04-11 17:29:23 -040085## Intent: Display command help
86## -----------------------------------------------------------------------
87help-summary ::
Joey Armstrongf548adc2023-09-08 15:59:42 -040088 @echo ' lint-groovy Conditionally lint groovy source'
Joey Armstrongf548adc2023-09-08 15:59:42 -040089 ifdef VERBOSE
Joey Armstrong686d3b92023-09-15 17:59:59 -040090 @echo ' lint-groovy-all Lint all available sources'
91 @echo ' lint-groovy-mod Lint locally modified (git status)'
92 @echo ' lint-groovy-src Lint individually (BY_SRC=list-of-files)'
Joey Armstrongf548adc2023-09-08 15:59:42 -040093 endif
Joey Armstrong686d3b92023-09-15 17:59:59 -040094
Joey Armstrong0205d332023-04-11 17:29:23 -040095# [EOF]