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