Makefile edits to improve library lint target support.
Makefile
--------
o Replace inlined includes with single $(MAKEDIR)/include.mk
o virtualenv install w/dependencies handled by makefiles/virtualenv.mk
o Use '&&' for command separation to improve error handling.
o Added more target documentation.
o Re-home doc8/rst syntax checking into makefiles/lint/doc8.mk.
howto/code/linting.rst
----------------------
o Document supported lint targets on docs.voltha.org.
howto/release/index.rst
howto/release/post-release/
howto/release/vcs/
---------------------------
o Document more release related activity (bugfix branch creation)
makefiles/consts.mk
-------------------
o Define and use more library macros.
config.mk
---------
o Per-repository library makefile configuration, disable linting.
makefiles/virtualenv.mk
-----------------------
o Library virtualenv install with dependences.
o Begin using a consistent install directory.
o Ugh: repository (voltha-docs) submodules each install a full venv.
o Install dependency drive based on existence of activate script.
o Lint targets updated to use activate script as a dependency.
o Update activate macro to run: set -u && activate && set +u
makefiles/patches/include.mk
----------------------------
o Update to use virtualenv.mk defined macros.
makefiles/lint/doc8.mk
makefiles/lint/python/flake8.mk
makefiles/lint/json.mk
makefiles/lint/python/pylint.mk
makefiles/lint/robot.mk
makefiles/lint/shell.mk
makefiles/lint/yaml.mk
-------------------------------
o All library linting defines consistent targets and logic.
o Support two library targets: lint-all and lint-modified.
o Default to checking all available sources.
o Linting can be disabled per-repository via {project}/config.mk
Change-Id: I7b7b5e523c867183d44244a0da21cfa3584e9a50
diff --git a/makefiles/lint/robot.mk b/makefiles/lint/robot.mk
index 1c7119f..fa8175c 100644
--- a/makefiles/lint/robot.mk
+++ b/makefiles/lint/robot.mk
@@ -1,8 +1,8 @@
# -*- makefile -*-
# -----------------------------------------------------------------------
-# Copyright 2017-2023 Open Networking Foundation
+# Copyright 2017-2023 Open Networking Foundation (ONF) and the ONF Contributors
#
-# Licensed under the Apache License, Version 2.0 (the "License");
+# Licensed under the Apache License, Version 2.0 (the "License")
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
@@ -15,7 +15,15 @@
# limitations under the License.
# -----------------------------------------------------------------------
-ROBOT_FILES ?= $(error ROBOT_FILES= is required)
+$(if $(DEBUG),$(warning ENTER))
+
+##-------------------##
+##---] GLOBALS [---##
+##-------------------##
+.PHONY: lint-robot lint-robot-all lint-robot-modified
+
+have-robot-files := $(if $(ROBOT_FILES),true)
+ROBOT_FILES ?= $(error ROBOT_FILES= required)
LINT_ARGS ?= --verbose --configure LineTooLong:130 -e LineTooLong \
--configure TooManyTestSteps:65 -e TooManyTestSteps \
@@ -25,17 +33,62 @@
--configure FileTooLong:2000 -e FileTooLong \
-e TrailingWhitespace
+## -----------------------------------------------------------------------
+## Intent: Use the robot command to perform syntax checking.
+## % make lint
+## % make lint-robot-all
+## % make lint-robot-modified
+## -----------------------------------------------------------------------
+ifndef NO-LINT-ROBOT
+ lint-robot-mode := $(if $(have-robot-files),modified,all)
+ lint : lint-robot-$(lint-robot-mode)
+endif# NO-LINT-ROBOT
-.PHONY: lint-robot
+## -----------------------------------------------------------------------
+## Intent: exhaustive robot syntax checking
+## -----------------------------------------------------------------------
+lint-robot-all:
+ $(HIDE)$(MAKE) --no-print-directory rflint-install
-lint : lint-robot
+ $(activate)\
+ && find . \( -iname '*.robot' \) -print0 \
+ | $(xargs-n1) rflint $(LINT_ARGS)
-lint-robot: vst_venv
- source ./$</bin/activate \
- ; set -u \
- ; rflint $(LINT_ARGS) $(ROBOT_FILES)
+## -----------------------------------------------------------------------
+## Intent: check deps for format and python3 cleanliness
+## Note:
+## robot --py3k option no longer supported
+## -----------------------------------------------------------------------
+lint-robot-modified: $(venv-activate-script)
+ $(HIDE)$(MAKE) --no-print-directory rflint-install
+ $(activate) && rflint $(LINT_ARGS) $(ROBOT_FILES)
+
+## -----------------------------------------------------------------------
+## Intent: Install the rflint command for syntax checking.
+## Note: requirements.txt pip install not used here ATM due to implicit
+## per-repository dependency config to enable checking.
+## -----------------------------------------------------------------------
+rflint-install: $(venv-activate-script)
+ @echo
+ @echo "** -----------------------------------------------------------------------"
+ @echo "** robot syntax checking"
+ @echo "** -----------------------------------------------------------------------"
+ $(activate)\
+ && pip install --upgrade robotframework-lint
+ $(activate) && rflint --version
+ @echo
+
+## -----------------------------------------------------------------------
+## Intent: Display command usage
+## -----------------------------------------------------------------------
help::
- @echo " lint-robot Syntax check robot sources using rflint"
+ @echo ' lint-robot Syntax check python using the robot command'
+ ifdef VERBOSE
+ @echo ' lint-robot-all robot checking: exhaustive'
+ @echo ' lint-robot-modified robot checking: only modified'
+ endif
+
+$(if $(DEBUG),$(warning LEAVE))
# [EOF]