Improve target coverage for the reuse license checker.
misc
----
o Copyright notice update from onf v1 to onf v1.1
makefiles/etc/utils.mk
----------------------
o Function path-by-makefilepath-by-makefile():
- Replace $(subst include.mk) with $(dir) so path construction becomes generic.
- Added wrapper function genpath-makefiles() to improve call usability.
makefiles/lint/license/include.mk
makefiles/lint/license/reuse.mk
makefiles/lint/license/install.mk
---------------------------------
o Added requirements.txt for reuse tool install (ability to vesion and freeze for release).
o Define command var REUSE= so local devs can override.
o Added banner-{enter,leave} for logfile visibility.
makefiles/lint/license/include.mk
makefiles/lint/license/help.mk
------------------------------
o Document a few missing targets for 'make help' and 'make lint-reuse-help'.
[HOWTO: test]
-------------
% make sterile
% make venv # install virtualenv
% make lint-reuse-install
% make sterile
% make lint-reuse-version
% make sterile
% make lint-reuse
Change-Id: I91f4789981f3d3c5bc744d2db99374f9790e3b98
diff --git a/makefiles/lint/license/help.mk b/makefiles/lint/license/help.mk
index ffd98bd..02ae791 100644
--- a/makefiles/lint/license/help.mk
+++ b/makefiles/lint/license/help.mk
@@ -42,6 +42,8 @@
'License check locally modified files (git status)'
@printf ' %-30s %s\n' 'lint-reuse-src'\
'License check files by path'
+ @printf ' %-30s %s\n' 'lint-reuse-install'\
+ 'pip install --requirements ./conf reuse'
$(if $(DEBUG),$(warning LEAVE))
diff --git a/makefiles/lint/license/include.mk b/makefiles/lint/license/include.mk
index b8f70f4..2f8e497 100644
--- a/makefiles/lint/license/include.mk
+++ b/makefiles/lint/license/include.mk
@@ -15,6 +15,11 @@
# limitations under the License.
# -----------------------------------------------------------------------
+##-------------------##
+##---] GLOBALS [---##
+##-------------------##
+REUSE ?= $(venv-activate-bin)/reuse
+
##--------------------##
##---] INCLUDES [---##
##--------------------##
@@ -23,7 +28,7 @@
include $(ONF_MAKEDIR)/lint/license/reuse.mk
# Alias targets
-lint-license : lint-reuse
+lint-license : lint-reuse
lint-license-all : lint-reuse-all
lint-license-mod : lint-reuse-mod
lint-license-src : lint-reuse-src
diff --git a/makefiles/lint/license/install.mk b/makefiles/lint/license/install.mk
index c708482..abaa778 100644
--- a/makefiles/lint/license/install.mk
+++ b/makefiles/lint/license/install.mk
@@ -1,6 +1,6 @@
# -*- makefile -*-
# -----------------------------------------------------------------------
-# Copyright 2022-2023 Open Networking Foundation (ONF) and the ONF Contributors
+# Copyright 2022-2024 Open Networking Foundation Contributors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -13,30 +13,24 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
-#
-# SPDX-FileCopyrightText: 2022 Open Networking Foundation (ONF) and the ONF Contributors
+# -----------------------------------------------------------------------
+# SPDX-FileCopyrightText: 2022-2024 Open Networking Foundation Contributors
# SPDX-License-Identifier: Apache-2.0
# -----------------------------------------------------------------------
+## Intent: This makefile will install the reuse tool used for license checking
+## -----------------------------------------------------------------------
$(if $(DEBUG),$(warning ENTER))
## -----------------------------------------------------------------------
-## Intent: Install the reuse tool
-## -----------------------------------------------------------------------
-
-## Define a macro to standardize and simplify access
-# REUSE ?= $(venv-activate-bin)/reuse
-# REUSE ?= $(activate) && reuse
-
-## -----------------------------------------------------------------------
## Intent: Display reuse command version string.
## Note: As a side effect, install reuse by dependency
## -----------------------------------------------------------------------
-.PHONY: lint-reuse-cmd-version
-lint-reuse-cmd-version : $(venv-activate-bin)/reuse
+.PHONY: lint-reuse-version
+lint-reuse-version : lint-reuse-install
$(HIDE) echo
- $< --version
+ $(venv-activate-bin)/reuse --version
## -----------------------------------------------------------------------
## Intent: On-demand instalation of the reuse command
@@ -61,9 +55,19 @@
help::
@printf ' %-30s %s\n' 'lint-reuse-install'\
'Install the reuse compliance tool'
+ @printf ' %-30s %s\n' 'lint-reuse-version'\
+ 'Display version of the installed reuse tool'
+
+# [NOTES]
+## -----------------------------------------------------------------------
+## o Installable tool target explicitly defined as $(venv-activate-bin)/reuse.
+## o Var $(REUSE) is not used as a dependency due to arbitray command
+## assignment with arguments. ie: make REUSE=/opt/reuse/bin/reuse
+## -----------------------------------------------------------------------
# [SEE ALSO]
# -----------------------------------------------------------------------
# o https://github.com/fsfe/reuse-tool#install
+## -----------------------------------------------------------------------
# [EOF]
diff --git a/makefiles/lint/license/requirements.txt b/makefiles/lint/license/requirements.txt
new file mode 100644
index 0000000..69d55a0
--- /dev/null
+++ b/makefiles/lint/license/requirements.txt
@@ -0,0 +1,5 @@
+# -*- makefile -*-
+
+reuse~=3.0.1
+
+# [EOF]
diff --git a/makefiles/lint/license/reuse.mk b/makefiles/lint/license/reuse.mk
index 408a329..306ab76 100644
--- a/makefiles/lint/license/reuse.mk
+++ b/makefiles/lint/license/reuse.mk
@@ -18,11 +18,15 @@
##-------------------##
##---] GLOBALS [---##
##-------------------##
+$(call genpath-makefiles,lint-reuse-req-txt,requirements.txt)
+# $(error lint-reuse-req-text=$(lint-reuse-req-txt))
##-------------------##
##---] TARGETS [---##
##-------------------##
ifndef NO-LINT-REUSE
+# lint-reuse-mode := $(if $(have-reuse-files),mod,all)
+# lint : lint-reuse-$(lint-reuse-mode)
lint : lint-reuse
endif
@@ -33,7 +37,10 @@
## -----------------------------------------------------------------------
## Intent: Perform a lint check on makefile sources
## -----------------------------------------------------------------------
-lint-reuse:
- reuse --root . lint
+lint-reuse : lint-reuse-version
+
+ $(call banner-enter,Target $@)
+ $(activate) && $(REUSE) --root . lint
+ $(call banner-enter,Target $@)
# [EOF]
diff --git a/makefiles/lint/license/urls b/makefiles/lint/license/urls
new file mode 100644
index 0000000..5c92557
--- /dev/null
+++ b/makefiles/lint/license/urls
@@ -0,0 +1,2 @@
+https://git.fsfe.org/reuse/tool
+https://reuse.software/tutorial/
diff --git a/makefiles/utils/include.mk b/makefiles/utils/include.mk
index 6090a17..e3e9ae0 100644
--- a/makefiles/utils/include.mk
+++ b/makefiles/utils/include.mk
@@ -39,15 +39,39 @@
## groovy-check-conf := $(call path-by-makefile,.groovylintrc.json)
## groovy-cmd = npm-groovy-lint --config "$(groovy-check-conf)"
## -----------------------------------------------------------------------
-path-by-makefile = $(strip \
+path-by-makefilepath-by-makefile = $(strip \
$(foreach filename,$(1),\
$(foreach makefile,$(lastword $(MAKEFILE_LIST)),\
- $(foreach makedir,$(subst /include.mk,$(null),$(makefile)),\
- $(makedir)/$(filename)\
+ $(foreach makedir,$(dir $(makefile)),\
+ $(makedir)$(filename)\
)\
))\
)
+## -----------------------------------------------------------------------
+## Intent: Improve function usability for path-by-makefilepath-by-makefile
+## -----------------------------------------------------------------------
+## Given:
+## scalar A makefile variable name to define
+## scalar Path within a makefile subdirectory to construct
+## Return:
+## scalar Constructed path for the given filename
+## -----------------------------------------------------------------------
+## Usage:
+## $(call genpath-makefiles,tox-ini,tox.ini)
+## $(info tox-ini = $(tox-ini))
+## -----------------------------------------------------------------------
+genpath-makefiles = $(strip \
+\
+ $(foreach var,$(1),\
+ $(foreach fyl,$(2),\
+ $(if true$(DEBUG),\
+ $(info $$(eval $(var) := $$(call path-by-makefilepath-by-makefile,$(fyl)))))\
+ $(eval $(var) := $(call path-by-makefilepath-by-makefile,$(fyl)))\
+ ))\
+ $(var)\
+)
+
$(if $(DEBUG),$(warning LEAVE))
# [EOF]