Joey Armstrong | 88fca72 | 2024-01-31 22:52:17 -0500 | [diff] [blame] | 1 | # -*- makefile -*- |
| 2 | # ----------------------------------------------------------------------- |
Joey Armstrong | dc04c93 | 2024-04-01 12:14:21 -0400 | [diff] [blame] | 3 | # Copyright 2017-2024 Open Networking Foundation Contributors |
Joey Armstrong | 88fca72 | 2024-01-31 22:52:17 -0500 | [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 | # |
Joey Armstrong | dc04c93 | 2024-04-01 12:14:21 -0400 | [diff] [blame] | 9 | # http:#www.apache.org/licenses/LICENSE-2.0 |
Joey Armstrong | 88fca72 | 2024-01-31 22:52:17 -0500 | [diff] [blame] | 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 | dc04c93 | 2024-04-01 12:14:21 -0400 | [diff] [blame] | 17 | # SPDX-FileCopyrightText: 2017-2024 Open Networking Foundation Contributors |
| 18 | # SPDX-License-Identifier: Apache-2.0 |
| 19 | # ----------------------------------------------------------------------- |
| 20 | # Intent: |
| 21 | # ----------------------------------------------------------------------- |
Joey Armstrong | 88fca72 | 2024-01-31 22:52:17 -0500 | [diff] [blame] | 22 | |
| 23 | $(if $(DEBUG),$(warning ENTER)) |
| 24 | |
| 25 | ##-------------------## |
| 26 | ##---] GLOBALS [---## |
| 27 | ##-------------------## |
| 28 | .PHONY: lint-robot lint-robot-all lint-robot-mod lint-robot-src |
| 29 | |
| 30 | have-robot-files := $(if $(strip $(ROBOT_FILES)),true) |
| 31 | ROBOT_FILES ?= $(error ROBOT_FILES= is required) |
| 32 | |
| 33 | robot-check = $(activate) && rflint |
| 34 | robot-check-args ?= --verbose --configure LineTooLong:130 -e LineTooLong \ |
| 35 | --configure TooManyTestSteps:65 -e TooManyTestSteps \ |
| 36 | --configure TooManyTestCases:50 -e TooManyTestCases \ |
| 37 | --configure TooFewTestSteps:1 \ |
| 38 | --configure TooFewKeywordSteps:1 \ |
| 39 | --configure FileTooLong:2000 -e FileTooLong \ |
| 40 | -e TrailingWhitespace |
| 41 | |
| 42 | ## ----------------------------------------------------------------------- |
| 43 | ## Intent: Use the robot command to perform syntax checking. |
| 44 | ## ----------------------------------------------------------------------- |
| 45 | ifndef NO-LINT-ROBOT |
| 46 | lint-robot-mode := $(if $(have-robot-files),mod,all) |
| 47 | lint : lint-robot |
| 48 | lint-robot : lint-robot-$(lint-robot-mode) |
| 49 | endif# NO-LINT-ROBOT |
| 50 | |
| 51 | ## ----------------------------------------------------------------------- |
| 52 | ## Intent: exhaustive robot syntax checking |
| 53 | ## ----------------------------------------------------------------------- |
| 54 | lint-robot-all: |
| 55 | |
| 56 | $(call banner-enter,Target $@) |
| 57 | |
| 58 | $(HIDE)$(MAKE) --no-print-directory lint-robot-version |
| 59 | @find . -iname '*.robot' -print0 \ |
| 60 | | $(xargs-n1) bash -c "$(robot-check) $(robot-check-args)" |
| 61 | @echo "DONE" |
| 62 | |
| 63 | $(call banner-leave,Target $@) |
| 64 | |
| 65 | ## ----------------------------------------------------------------------- |
| 66 | ## Intent: On-demand lint checking |
| 67 | ## ----------------------------------------------------------------------- |
| 68 | lint-robot-src: |
| 69 | ifndef ROBOT_SRC |
| 70 | @echo "ERROR: Usage: $(MAKE) $@ ROBOT_SRC=" |
| 71 | @exit 1 |
| 72 | endif |
| 73 | |
| 74 | $(call banner-enter,Target $@) |
| 75 | |
| 76 | $(HIDE)$(MAKE) --no-print-directory lint-robot-version |
| 77 | $(HIDE) $(robot-check-args) $(robot-check-args) $(ROBOT_SRC) |
| 78 | |
| 79 | $(call banner-leave,Target $@) |
| 80 | |
| 81 | ## ----------------------------------------------------------------------- |
| 82 | ## Intent: Perform lint check on locally modified sources |
| 83 | ## ----------------------------------------------------------------------- |
| 84 | lint-robot-bygit = $(shell git ls-files -m -o | grep -i '\.robot') |
| 85 | lint-robot-mod: |
| 86 | $(call banner-enter,Target $@) |
| 87 | |
| 88 | $(HIDE)$(MAKE) --no-print-directory lint-robot-version |
| 89 | $(foreach fyl,$(lint-robot-bygit),$(robot-check) $(robot-check-args) $(fyl)) |
| 90 | |
| 91 | $(call banner-leave,Target $@) |
| 92 | |
| 93 | $(if $(DEBUG),$(warning LEAVE)) |
| 94 | |
| 95 | # [EOF] |