From 5ed04d88b8ce56000ea454f55b10c1d2ec6fdaf4 Mon Sep 17 00:00:00 2001 From: "Xinwei Xiong(cubxxw)" <3293172751nss@gmail.com> Date: Thu, 11 May 2023 02:04:23 +0800 Subject: [PATCH] feat(makefile): add the rights management is from openim Signed-off-by: Xinwei Xiong(cubxxw) <3293172751nss@gmail.com> --- script/make-rules/copyright.mk | 43 +++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/script/make-rules/copyright.mk b/script/make-rules/copyright.mk index 052159e10..00277ad48 100644 --- a/script/make-rules/copyright.mk +++ b/script/make-rules/copyright.mk @@ -15,4 +15,45 @@ # ============================================================================== # wget https://github.com/google/addlicense/releases/download/v1.0.0/addlicense_1.0.0_Linux_x86_64.tar.gz # Makefile helper functions for copyright -# \ No newline at end of file +# + +LICENSE_TEMPLATE ?= $(ROOT_DIR)/scripts/LICENSE_TEMPLATE + +# TODO: GOBIN -> TOOLS_DIR +# Questions about go mod instead of go path: https://github.com/kubernetes/kubernetes/issues/117181 +## copyright.verify: Validate boilerplate headers for assign files +.PHONY: copyright.verify +copyright.verify: tools.verify.addlicense + @echo "===========> Validate boilerplate headers for assign files starting in the $(ROOT_DIR) directory" + @$(GOBIN)/addlicense -v -check -ignore **/test/** -f $(LICENSE_TEMPLATE) $(CODE_DIRS) + @echo "===========> End of boilerplate headers check..." + +## copyright.add: Add the boilerplate headers for all files +.PHONY: copyright.add +copyright.add: tools.verify.addlicense + @echo "===========> Adding $(LICENSE_TEMPLATE) the boilerplate headers for all files" + @$(GOBIN)/addlicense -y $(shell date +"%Y") -v -c "Alibaba Group Holding Ltd." -f $(LICENSE_TEMPLATE) $(CODE_DIRS) + @echo "===========> End the copyright is added..." + +# Addlicense Flags: +# -c string +# copyright holder (default "Google LLC") +# -check +# check only mode: verify presence of license headers and exit with non-zero code if missing +# -f string +# license file +# -ignore value +# file patterns to ignore, for example: -ignore **/*.go -ignore vendor/** +# -l string +# license type: apache, bsd, mit, mpl (default "apache") +# -s Include SPDX identifier in license header. Set -s=only to only include SPDX identifier. +# -skip value +# [deprecated: see -ignore] file extensions to skip, for example: -skip rb -skip go +# -v verbose mode: print the name of the files that are modified or were skipped +# -y string +# copyright year(s) (default "2023") + +## copyright.help: Show copyright help +.PHONY: copyright.help +copyright.help: scripts/make-rules/copyright.mk + $(call smallhelp) \ No newline at end of file