Joey Armstrong | 0205d33 | 2023-04-11 17:29:23 -0400 | [diff] [blame] | 1 | # -*- makefile -*- |
| 2 | # ----------------------------------------------------------------------- |
Joey Armstrong | a3f9aca | 2024-02-11 11:58:11 -0500 | [diff] [blame] | 3 | # Copyright 2022-2024 Open Networking Foundation (ONF) and the ONF Contributors |
Joey Armstrong | 0205d33 | 2023-04-11 17:29:23 -0400 | [diff] [blame] | 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 | # ----------------------------------------------------------------------- |
| 17 | |
| 18 | ##-------------------## |
| 19 | ##---] GLOBALS [---## |
| 20 | ##-------------------## |
| 21 | |
| 22 | groovy-check := npm-groovy-lint |
| 23 | |
Joey Armstrong | a3f9aca | 2024-02-11 11:58:11 -0500 | [diff] [blame] | 24 | groovy-check-conf := $(call path-by-makefile,.groovylintrc.json) |
| 25 | |
Joey Armstrong | 0205d33 | 2023-04-11 17:29:23 -0400 | [diff] [blame] | 26 | groovy-check-args := $(null) |
Joey Armstrong | a3f9aca | 2024-02-11 11:58:11 -0500 | [diff] [blame] | 27 | groovy-check-args += --config "$(groovy-check-conf)" |
| 28 | |
Joey Armstrong | 0205d33 | 2023-04-11 17:29:23 -0400 | [diff] [blame] | 29 | # groovy-check-args += --loglevel info |
| 30 | # groovy-check-args += --ignorepattern |
| 31 | # groovy-check-args += --verbose |
| 32 | |
| 33 | ##-------------------## |
| 34 | ##---] TARGETS [---## |
| 35 | ##-------------------## |
Joey Armstrong | 686d3b9 | 2023-09-15 17:59:59 -0400 | [diff] [blame] | 36 | |
| 37 | ## ----------------------------------------------------------------------- |
| 38 | ## Intent: Enabled by repository_sandbox_root/config.mk |
| 39 | ## ----------------------------------------------------------------------- |
Joey Armstrong | 0205d33 | 2023-04-11 17:29:23 -0400 | [diff] [blame] | 40 | ifndef NO-LINT-GROOVY |
| 41 | lint : lint-groovy |
| 42 | endif |
| 43 | |
| 44 | ## ----------------------------------------------------------------------- |
Joey Armstrong | f548adc | 2023-09-08 15:59:42 -0400 | [diff] [blame] | 45 | ## All or on-demand |
| 46 | ## make lint-groovy BY_SRC="a/b/c.groovy d/e/f.groovy" |
| 47 | ## ----------------------------------------------------------------------- |
Joey Armstrong | 686d3b9 | 2023-09-15 17:59:59 -0400 | [diff] [blame] | 48 | ifdef GROOVY_SRC |
Joey Armstrong | f548adc | 2023-09-08 15:59:42 -0400 | [diff] [blame] | 49 | lint-groovy : lint-groovy-src |
| 50 | else |
| 51 | lint-groovy : lint-groovy-all |
| 52 | endif |
| 53 | |
| 54 | ## ----------------------------------------------------------------------- |
Joey Armstrong | 0205d33 | 2023-04-11 17:29:23 -0400 | [diff] [blame] | 55 | ## Intent: Perform a lint check on command line script sources |
| 56 | ## ----------------------------------------------------------------------- |
Joey Armstrong | f548adc | 2023-09-08 15:59:42 -0400 | [diff] [blame] | 57 | lint-groovy-all: |
Joey Armstrong | 88fca72 | 2024-01-31 22:52:17 -0500 | [diff] [blame] | 58 | |
| 59 | $(call banner-enter,Target $@) |
| 60 | |
Joey Armstrong | 0205d33 | 2023-04-11 17:29:23 -0400 | [diff] [blame] | 61 | $(groovy-check) --version |
| 62 | @echo |
| 63 | $(HIDE)$(env-clean) find . -iname '*.groovy' -print0 \ |
| 64 | | $(xargs-n1) $(groovy-check) $(groovy-check-args) |
| 65 | |
Joey Armstrong | 88fca72 | 2024-01-31 22:52:17 -0500 | [diff] [blame] | 66 | $(call banner-leave,Target $@) |
| 67 | |
Joey Armstrong | 0205d33 | 2023-04-11 17:29:23 -0400 | [diff] [blame] | 68 | ## ----------------------------------------------------------------------- |
Joey Armstrong | 686d3b9 | 2023-09-15 17:59:59 -0400 | [diff] [blame] | 69 | ## Intent: On-demand lint checking |
Joey Armstrong | f548adc | 2023-09-08 15:59:42 -0400 | [diff] [blame] | 70 | ## ----------------------------------------------------------------------- |
Joey Armstrong | f548adc | 2023-09-08 15:59:42 -0400 | [diff] [blame] | 71 | lint-groovy-src: |
Joey Armstrong | 686d3b9 | 2023-09-15 17:59:59 -0400 | [diff] [blame] | 72 | ifndef GROOVY_SRC |
| 73 | @echo "ERROR: Usage: $(MAKE) $@ GROOVY_SRC=" |
| 74 | @exit 1 |
| 75 | endif |
Joey Armstrong | f548adc | 2023-09-08 15:59:42 -0400 | [diff] [blame] | 76 | $(groovy-check) --version |
| 77 | @echo |
Joey Armstrong | 686d3b9 | 2023-09-15 17:59:59 -0400 | [diff] [blame] | 78 | $(HIDE) $(groovy-check) $(groovy-check-args) $(GROOVY_SRC) |
Joey Armstrong | f548adc | 2023-09-08 15:59:42 -0400 | [diff] [blame] | 79 | |
| 80 | ## ----------------------------------------------------------------------- |
Joey Armstrong | 88fca72 | 2024-01-31 22:52:17 -0500 | [diff] [blame] | 81 | ## Intent: Perform lint check on locally modified sources |
Joey Armstrong | f548adc | 2023-09-08 15:59:42 -0400 | [diff] [blame] | 82 | ## ----------------------------------------------------------------------- |
Joey Armstrong | 686d3b9 | 2023-09-15 17:59:59 -0400 | [diff] [blame] | 83 | # lint-groovy-bygit = $(shell git diff --name-only HEAD | grep '\.groovy') |
| 84 | 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] | 85 | lint-groovy-mod: |
| 86 | $(groovy-check) --version |
| 87 | @echo |
Joey Armstrong | 686d3b9 | 2023-09-15 17:59:59 -0400 | [diff] [blame] | 88 | $(foreach fyl,$(lint-groovy-bygit),$(groovy-check) $(groovy-check-args) $(fyl)) |
Joey Armstrong | f548adc | 2023-09-08 15:59:42 -0400 | [diff] [blame] | 89 | |
| 90 | ## ----------------------------------------------------------------------- |
Joey Armstrong | 0205d33 | 2023-04-11 17:29:23 -0400 | [diff] [blame] | 91 | ## Intent: Display command help |
| 92 | ## ----------------------------------------------------------------------- |
| 93 | help-summary :: |
Joey Armstrong | f548adc | 2023-09-08 15:59:42 -0400 | [diff] [blame] | 94 | @echo ' lint-groovy Conditionally lint groovy source' |
Joey Armstrong | f548adc | 2023-09-08 15:59:42 -0400 | [diff] [blame] | 95 | ifdef VERBOSE |
Joey Armstrong | 686d3b9 | 2023-09-15 17:59:59 -0400 | [diff] [blame] | 96 | @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 Armstrong | f548adc | 2023-09-08 15:59:42 -0400 | [diff] [blame] | 99 | endif |
Joey Armstrong | 686d3b9 | 2023-09-15 17:59:59 -0400 | [diff] [blame] | 100 | |
Joey Armstrong | 0205d33 | 2023-04-11 17:29:23 -0400 | [diff] [blame] | 101 | # [EOF] |