Joey Armstrong | 0205d33 | 2023-04-11 17:29:23 -0400 | [diff] [blame] | 1 | # -*- 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 Armstrong | 686d3b9 | 2023-09-15 17:59:59 -0400 | [diff] [blame] | 17 | # https://gerrit.opencord.org/plugins/gitiles/onf-make |
| 18 | # ONF.makefiles.lint.groovy.version = 1.1.1 (+local edits) |
| 19 | # ----------------------------------------------------------------------- |
Joey Armstrong | 0205d33 | 2023-04-11 17:29:23 -0400 | [diff] [blame] | 20 | |
| 21 | ##-------------------## |
| 22 | ##---] GLOBALS [---## |
| 23 | ##-------------------## |
| 24 | |
| 25 | groovy-check := npm-groovy-lint |
| 26 | |
| 27 | groovy-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 Armstrong | 686d3b9 | 2023-09-15 17:59:59 -0400 | [diff] [blame] | 35 | |
| 36 | ## ----------------------------------------------------------------------- |
| 37 | ## Intent: Enabled by repository_sandbox_root/config.mk |
| 38 | ## ----------------------------------------------------------------------- |
Joey Armstrong | 0205d33 | 2023-04-11 17:29:23 -0400 | [diff] [blame] | 39 | ifndef NO-LINT-GROOVY |
| 40 | lint : lint-groovy |
| 41 | endif |
| 42 | |
| 43 | ## ----------------------------------------------------------------------- |
Joey Armstrong | f548adc | 2023-09-08 15:59:42 -0400 | [diff] [blame] | 44 | ## All or on-demand |
| 45 | ## make lint-groovy BY_SRC="a/b/c.groovy d/e/f.groovy" |
| 46 | ## ----------------------------------------------------------------------- |
Joey Armstrong | 686d3b9 | 2023-09-15 17:59:59 -0400 | [diff] [blame] | 47 | ifdef GROOVY_SRC |
Joey Armstrong | f548adc | 2023-09-08 15:59:42 -0400 | [diff] [blame] | 48 | lint-groovy : lint-groovy-src |
| 49 | else |
| 50 | lint-groovy : lint-groovy-all |
| 51 | endif |
| 52 | |
| 53 | ## ----------------------------------------------------------------------- |
Joey Armstrong | 0205d33 | 2023-04-11 17:29:23 -0400 | [diff] [blame] | 54 | ## Intent: Perform a lint check on command line script sources |
| 55 | ## ----------------------------------------------------------------------- |
Joey Armstrong | f548adc | 2023-09-08 15:59:42 -0400 | [diff] [blame] | 56 | lint-groovy-all: |
Joey Armstrong | 0205d33 | 2023-04-11 17:29:23 -0400 | [diff] [blame] | 57 | $(groovy-check) --version |
| 58 | @echo |
| 59 | $(HIDE)$(env-clean) find . -iname '*.groovy' -print0 \ |
| 60 | | $(xargs-n1) $(groovy-check) $(groovy-check-args) |
| 61 | |
| 62 | ## ----------------------------------------------------------------------- |
Joey Armstrong | 686d3b9 | 2023-09-15 17:59:59 -0400 | [diff] [blame] | 63 | ## Intent: On-demand lint checking |
Joey Armstrong | f548adc | 2023-09-08 15:59:42 -0400 | [diff] [blame] | 64 | ## ----------------------------------------------------------------------- |
Joey Armstrong | f548adc | 2023-09-08 15:59:42 -0400 | [diff] [blame] | 65 | lint-groovy-src: |
Joey Armstrong | 686d3b9 | 2023-09-15 17:59:59 -0400 | [diff] [blame] | 66 | ifndef GROOVY_SRC |
| 67 | @echo "ERROR: Usage: $(MAKE) $@ GROOVY_SRC=" |
| 68 | @exit 1 |
| 69 | endif |
Joey Armstrong | f548adc | 2023-09-08 15:59:42 -0400 | [diff] [blame] | 70 | $(groovy-check) --version |
| 71 | @echo |
Joey Armstrong | 686d3b9 | 2023-09-15 17:59:59 -0400 | [diff] [blame] | 72 | $(HIDE) $(groovy-check) $(groovy-check-args) $(GROOVY_SRC) |
Joey Armstrong | f548adc | 2023-09-08 15:59:42 -0400 | [diff] [blame] | 73 | |
| 74 | ## ----------------------------------------------------------------------- |
| 75 | ## Intent: Perform lint check on a named list of files |
| 76 | ## ----------------------------------------------------------------------- |
Joey Armstrong | 686d3b9 | 2023-09-15 17:59:59 -0400 | [diff] [blame] | 77 | # lint-groovy-bygit = $(shell git diff --name-only HEAD | grep '\.groovy') |
| 78 | lint-groovy-bygit = $(git status -s | grep '\.sh' | grep -v -e '^D' -e '^?' | cut -c4-) |
Joey Armstrong | f548adc | 2023-09-08 15:59:42 -0400 | [diff] [blame] | 79 | lint-groovy-mod: |
| 80 | $(groovy-check) --version |
| 81 | @echo |
Joey Armstrong | 686d3b9 | 2023-09-15 17:59:59 -0400 | [diff] [blame] | 82 | $(foreach fyl,$(lint-groovy-bygit),$(groovy-check) $(groovy-check-args) $(fyl)) |
Joey Armstrong | f548adc | 2023-09-08 15:59:42 -0400 | [diff] [blame] | 83 | |
| 84 | ## ----------------------------------------------------------------------- |
Joey Armstrong | 0205d33 | 2023-04-11 17:29:23 -0400 | [diff] [blame] | 85 | ## Intent: Display command help |
| 86 | ## ----------------------------------------------------------------------- |
| 87 | help-summary :: |
Joey Armstrong | f548adc | 2023-09-08 15:59:42 -0400 | [diff] [blame] | 88 | @echo ' lint-groovy Conditionally lint groovy source' |
Joey Armstrong | f548adc | 2023-09-08 15:59:42 -0400 | [diff] [blame] | 89 | ifdef VERBOSE |
Joey Armstrong | 686d3b9 | 2023-09-15 17:59:59 -0400 | [diff] [blame] | 90 | @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 Armstrong | f548adc | 2023-09-08 15:59:42 -0400 | [diff] [blame] | 93 | endif |
Joey Armstrong | 686d3b9 | 2023-09-15 17:59:59 -0400 | [diff] [blame] | 94 | |
Joey Armstrong | 0205d33 | 2023-04-11 17:29:23 -0400 | [diff] [blame] | 95 | # [EOF] |