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 | 88fca72 | 2024-01-31 22:52:17 -0500 | [diff] [blame] | 57 | |
| 58 | $(call banner-enter,Target $@) |
| 59 | |
Joey Armstrong | 0205d33 | 2023-04-11 17:29:23 -0400 | [diff] [blame] | 60 | $(groovy-check) --version |
| 61 | @echo |
| 62 | $(HIDE)$(env-clean) find . -iname '*.groovy' -print0 \ |
| 63 | | $(xargs-n1) $(groovy-check) $(groovy-check-args) |
| 64 | |
Joey Armstrong | 88fca72 | 2024-01-31 22:52:17 -0500 | [diff] [blame] | 65 | $(call banner-leave,Target $@) |
| 66 | |
Joey Armstrong | 0205d33 | 2023-04-11 17:29:23 -0400 | [diff] [blame] | 67 | ## ----------------------------------------------------------------------- |
Joey Armstrong | 686d3b9 | 2023-09-15 17:59:59 -0400 | [diff] [blame] | 68 | ## Intent: On-demand lint checking |
Joey Armstrong | f548adc | 2023-09-08 15:59:42 -0400 | [diff] [blame] | 69 | ## ----------------------------------------------------------------------- |
Joey Armstrong | f548adc | 2023-09-08 15:59:42 -0400 | [diff] [blame] | 70 | lint-groovy-src: |
Joey Armstrong | 686d3b9 | 2023-09-15 17:59:59 -0400 | [diff] [blame] | 71 | ifndef GROOVY_SRC |
| 72 | @echo "ERROR: Usage: $(MAKE) $@ GROOVY_SRC=" |
| 73 | @exit 1 |
| 74 | endif |
Joey Armstrong | f548adc | 2023-09-08 15:59:42 -0400 | [diff] [blame] | 75 | $(groovy-check) --version |
| 76 | @echo |
Joey Armstrong | 686d3b9 | 2023-09-15 17:59:59 -0400 | [diff] [blame] | 77 | $(HIDE) $(groovy-check) $(groovy-check-args) $(GROOVY_SRC) |
Joey Armstrong | f548adc | 2023-09-08 15:59:42 -0400 | [diff] [blame] | 78 | |
| 79 | ## ----------------------------------------------------------------------- |
Joey Armstrong | 88fca72 | 2024-01-31 22:52:17 -0500 | [diff] [blame] | 80 | ## Intent: Perform lint check on locally modified sources |
Joey Armstrong | f548adc | 2023-09-08 15:59:42 -0400 | [diff] [blame] | 81 | ## ----------------------------------------------------------------------- |
Joey Armstrong | 686d3b9 | 2023-09-15 17:59:59 -0400 | [diff] [blame] | 82 | # lint-groovy-bygit = $(shell git diff --name-only HEAD | grep '\.groovy') |
| 83 | 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] | 84 | lint-groovy-mod: |
| 85 | $(groovy-check) --version |
| 86 | @echo |
Joey Armstrong | 686d3b9 | 2023-09-15 17:59:59 -0400 | [diff] [blame] | 87 | $(foreach fyl,$(lint-groovy-bygit),$(groovy-check) $(groovy-check-args) $(fyl)) |
Joey Armstrong | f548adc | 2023-09-08 15:59:42 -0400 | [diff] [blame] | 88 | |
| 89 | ## ----------------------------------------------------------------------- |
Joey Armstrong | 0205d33 | 2023-04-11 17:29:23 -0400 | [diff] [blame] | 90 | ## Intent: Display command help |
| 91 | ## ----------------------------------------------------------------------- |
| 92 | help-summary :: |
Joey Armstrong | f548adc | 2023-09-08 15:59:42 -0400 | [diff] [blame] | 93 | @echo ' lint-groovy Conditionally lint groovy source' |
Joey Armstrong | f548adc | 2023-09-08 15:59:42 -0400 | [diff] [blame] | 94 | ifdef VERBOSE |
Joey Armstrong | 686d3b9 | 2023-09-15 17:59:59 -0400 | [diff] [blame] | 95 | @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 Armstrong | f548adc | 2023-09-08 15:59:42 -0400 | [diff] [blame] | 98 | endif |
Joey Armstrong | 686d3b9 | 2023-09-15 17:59:59 -0400 | [diff] [blame] | 99 | |
Joey Armstrong | 0205d33 | 2023-04-11 17:29:23 -0400 | [diff] [blame] | 100 | # [EOF] |