Joey Armstrong | 7f9c4df | 2022-12-26 19:39:59 -0500 | [diff] [blame] | 1 | # -*- makefile -*- |
| 2 | # ----------------------------------------------------------------------- |
Joey Armstrong | 1b6902d | 2024-01-02 15:43:57 -0500 | [diff] [blame] | 3 | # Copyright 2016-2024 Open Networking Foundation (ONF) and the ONF Contributors |
Holger Hildebrandt | da7758b | 2020-03-16 11:30:03 +0000 | [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 | # |
| 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. |
Joey Armstrong | 7f9c4df | 2022-12-26 19:39:59 -0500 | [diff] [blame] | 16 | # ----------------------------------------------------------------------- |
| 17 | |
| 18 | $(if $(DEBUG),$(warning ENTER)) |
| 19 | |
| 20 | .DEFAULT_GOAL := help |
| 21 | |
| 22 | TOP ?= . |
| 23 | MAKEDIR ?= $(TOP)/makefiles |
| 24 | |
| 25 | $(if $(VERBOSE),$(eval export VERBOSE=$(VERBOSE))) # visible to include(s) |
| 26 | |
| 27 | ##--------------------## |
| 28 | ##---] INCLUDES [---## |
| 29 | ##--------------------## |
| 30 | include $(MAKEDIR)/include.mk |
| 31 | ifdef LOCAL_LINT |
| 32 | include $(MAKEDIR)/lint/golang/sca.mk |
| 33 | endif |
Holger Hildebrandt | da7758b | 2020-03-16 11:30:03 +0000 | [diff] [blame] | 34 | |
| 35 | # set default shell |
| 36 | SHELL = bash -e -o pipefail |
| 37 | |
| 38 | # Variables |
| 39 | VERSION ?= $(shell cat ./VERSION) |
| 40 | |
| 41 | DOCKER_LABEL_VCS_DIRTY = false |
| 42 | ifneq ($(shell git ls-files --others --modified --exclude-standard 2>/dev/null | wc -l | sed -e 's/ //g'),0) |
| 43 | DOCKER_LABEL_VCS_DIRTY = true |
| 44 | endif |
Joey Armstrong | 7f9c4df | 2022-12-26 19:39:59 -0500 | [diff] [blame] | 45 | |
Joey Armstrong | 1b6902d | 2024-01-02 15:43:57 -0500 | [diff] [blame] | 46 | ## [TODO] Refactor with repo:onf-make:makefiles/docker/include.mk |
| 47 | |
Holger Hildebrandt | da7758b | 2020-03-16 11:30:03 +0000 | [diff] [blame] | 48 | ## Docker related |
| 49 | DOCKER_EXTRA_ARGS ?= |
| 50 | DOCKER_REGISTRY ?= |
| 51 | DOCKER_REPOSITORY ?= |
David K. Bainbridge | ee01bc4 | 2021-04-06 17:38:20 +0000 | [diff] [blame] | 52 | DOCKER_TAG ?= ${VERSION}$(shell [[ ${DOCKER_LABEL_VCS_DIRTY} == "true" ]] && echo "-dirty" || true) |
| 53 | DOCKER_TARGET ?= prod |
Holger Hildebrandt | da7758b | 2020-03-16 11:30:03 +0000 | [diff] [blame] | 54 | ADAPTER_IMAGENAME := ${DOCKER_REGISTRY}${DOCKER_REPOSITORY}voltha-openonu-adapter-go:${DOCKER_TAG} |
| 55 | TYPE ?= minimal |
| 56 | |
| 57 | ## Docker labels. Only set ref and commit date if committed |
| 58 | DOCKER_LABEL_VCS_URL ?= $(shell git remote get-url $(shell git remote)) |
| 59 | DOCKER_LABEL_VCS_REF = $(shell git rev-parse HEAD) |
| 60 | DOCKER_LABEL_BUILD_DATE ?= $(shell date -u "+%Y-%m-%dT%H:%M:%SZ") |
| 61 | DOCKER_LABEL_COMMIT_DATE = $(shell git show -s --format=%cd --date=iso-strict HEAD) |
| 62 | |
| 63 | DOCKER_BUILD_ARGS ?= \ |
| 64 | ${DOCKER_EXTRA_ARGS} \ |
| 65 | --build-arg org_label_schema_version="${VERSION}" \ |
| 66 | --build-arg org_label_schema_vcs_url="${DOCKER_LABEL_VCS_URL}" \ |
| 67 | --build-arg org_label_schema_vcs_ref="${DOCKER_LABEL_VCS_REF}" \ |
| 68 | --build-arg org_label_schema_build_date="${DOCKER_LABEL_BUILD_DATE}" \ |
| 69 | --build-arg org_opencord_vcs_commit_date="${DOCKER_LABEL_COMMIT_DATE}" \ |
| 70 | --build-arg org_opencord_vcs_dirty="${DOCKER_LABEL_VCS_DIRTY}" |
| 71 | |
| 72 | # tool containers |
David K. Bainbridge | d80007b | 2021-04-12 12:22:29 +0000 | [diff] [blame] | 73 | VOLTHA_TOOLS_VERSION ?= 2.4.0 |
Holger Hildebrandt | da7758b | 2020-03-16 11:30:03 +0000 | [diff] [blame] | 74 | |
| 75 | GO = docker run --rm --user $$(id -u):$$(id -g) -v ${CURDIR}:/app -v gocache:/.cache -v gocache-${VOLTHA_TOOLS_VERSION}:/go/pkg voltha/voltha-ci-tools:${VOLTHA_TOOLS_VERSION}-golang go |
| 76 | GO_JUNIT_REPORT = docker run --rm --user $$(id -u):$$(id -g) -v ${CURDIR}:/app -i voltha/voltha-ci-tools:${VOLTHA_TOOLS_VERSION}-go-junit-report go-junit-report |
Matteo Scandolo | 761f751 | 2020-11-23 15:52:40 -0800 | [diff] [blame] | 77 | GOCOVER_COBERTURA = docker run --rm --user $$(id -u):$$(id -g) -v ${CURDIR}:/app/src/github.com/opencord/voltha-openonu-adapter-go -i voltha/voltha-ci-tools:${VOLTHA_TOOLS_VERSION}-gocover-cobertura gocover-cobertura |
Holger Hildebrandt | da7758b | 2020-03-16 11:30:03 +0000 | [diff] [blame] | 78 | GOFMT = docker run --rm --user $$(id -u):$$(id -g) -v ${CURDIR}:/app voltha/voltha-ci-tools:${VOLTHA_TOOLS_VERSION}-golang gofmt |
| 79 | GOLANGCI_LINT = docker run --rm --user $$(id -u):$$(id -g) -v ${CURDIR}:/app -v gocache:/.cache -v gocache-${VOLTHA_TOOLS_VERSION}:/go/pkg voltha/voltha-ci-tools:${VOLTHA_TOOLS_VERSION}-golangci-lint golangci-lint |
| 80 | HADOLINT = docker run --rm --user $$(id -u):$$(id -g) -v ${CURDIR}:/app voltha/voltha-ci-tools:${VOLTHA_TOOLS_VERSION}-hadolint hadolint |
| 81 | |
David K. Bainbridge | ee01bc4 | 2021-04-06 17:38:20 +0000 | [diff] [blame] | 82 | .PHONY: docker-build local-protos local-lib-go help |
Holger Hildebrandt | da7758b | 2020-03-16 11:30:03 +0000 | [diff] [blame] | 83 | |
Joey Armstrong | 1b6902d | 2024-01-02 15:43:57 -0500 | [diff] [blame] | 84 | ## ----------------------------------------------------------------------- |
Holger Hildebrandt | da7758b | 2020-03-16 11:30:03 +0000 | [diff] [blame] | 85 | ## Local Development Helpers |
Joey Armstrong | 1b6902d | 2024-01-02 15:43:57 -0500 | [diff] [blame] | 86 | ## ----------------------------------------------------------------------- |
David K. Bainbridge | ee01bc4 | 2021-04-06 17:38:20 +0000 | [diff] [blame] | 87 | local-protos: ## Copies a local version of the voltha-protos dependency into the vendor directory |
Holger Hildebrandt | da7758b | 2020-03-16 11:30:03 +0000 | [diff] [blame] | 88 | ifdef LOCAL_PROTOS |
khenaidoo | 7d3c558 | 2021-08-11 18:09:44 -0400 | [diff] [blame] | 89 | rm -rf vendor/github.com/opencord/voltha-protos/v5/go |
| 90 | mkdir -p vendor/github.com/opencord/voltha-protos/v5/go |
| 91 | cp -r ${LOCAL_PROTOS}/go/* vendor/github.com/opencord/voltha-protos/v5/go |
| 92 | rm -rf vendor/github.com/opencord/voltha-protos/v5/go/vendor |
Holger Hildebrandt | da7758b | 2020-03-16 11:30:03 +0000 | [diff] [blame] | 93 | endif |
| 94 | |
Joey Armstrong | 1b6902d | 2024-01-02 15:43:57 -0500 | [diff] [blame] | 95 | ## ----------------------------------------------------------------------- |
Holger Hildebrandt | da7758b | 2020-03-16 11:30:03 +0000 | [diff] [blame] | 96 | ## Local Development Helpers |
Joey Armstrong | 1b6902d | 2024-01-02 15:43:57 -0500 | [diff] [blame] | 97 | ## ----------------------------------------------------------------------- |
David K. Bainbridge | ee01bc4 | 2021-04-06 17:38:20 +0000 | [diff] [blame] | 98 | local-lib-go: ## Copies a local version of the voltha-lib-go dependency into the vendor directory |
Holger Hildebrandt | da7758b | 2020-03-16 11:30:03 +0000 | [diff] [blame] | 99 | ifdef LOCAL_LIB_GO |
khenaidoo | 7d3c558 | 2021-08-11 18:09:44 -0400 | [diff] [blame] | 100 | rm -rf vendor/github.com/opencord/voltha-lib-go/v7/pkg |
| 101 | mkdir -p vendor/github.com/opencord/voltha-lib-go/v7/pkg |
| 102 | cp -r ${LOCAL_LIB_GO}/pkg/* vendor/github.com/opencord/voltha-lib-go/v7/pkg/ |
Holger Hildebrandt | da7758b | 2020-03-16 11:30:03 +0000 | [diff] [blame] | 103 | endif |
| 104 | |
Joey Armstrong | 7f9c4df | 2022-12-26 19:39:59 -0500 | [diff] [blame] | 105 | ## ----------------------------------------------------------------------- |
| 106 | ## ----------------------------------------------------------------------- |
David K. Bainbridge | ee01bc4 | 2021-04-06 17:38:20 +0000 | [diff] [blame] | 107 | build: docker-build ## Alias for 'docker build' |
| 108 | |
Joey Armstrong | 7f9c4df | 2022-12-26 19:39:59 -0500 | [diff] [blame] | 109 | ## ----------------------------------------------------------------------- |
Holger Hildebrandt | da7758b | 2020-03-16 11:30:03 +0000 | [diff] [blame] | 110 | ## Docker targets |
Joey Armstrong | 7f9c4df | 2022-12-26 19:39:59 -0500 | [diff] [blame] | 111 | ## ----------------------------------------------------------------------- |
Holger Hildebrandt | 6999fe5 | 2021-02-11 11:49:05 +0000 | [diff] [blame] | 112 | docker-build: local-protos local-lib-go ## Build openonu adapter docker image (set BUILD_PROFILED=true to also build the profiled image) |
David K. Bainbridge | 740ca85 | 2021-04-15 00:23:35 +0000 | [diff] [blame] | 113 | docker build $(DOCKER_BUILD_ARGS) --target=${DOCKER_TARGET} --build-arg CGO_PARAMETER=0 -t ${ADAPTER_IMAGENAME} -f docker/Dockerfile.openonu . |
Holger Hildebrandt | 6999fe5 | 2021-02-11 11:49:05 +0000 | [diff] [blame] | 114 | ifdef BUILD_PROFILED |
David K. Bainbridge | 740ca85 | 2021-04-15 00:23:35 +0000 | [diff] [blame] | 115 | docker build $(DOCKER_BUILD_ARGS) --target=dev --build-arg CGO_PARAMETER=1 --build-arg EXTRA_GO_BUILD_TAGS="-tags profile" -t ${ADAPTER_IMAGENAME}-profile -f docker/Dockerfile.openonu . |
| 116 | endif |
| 117 | ifdef BUILD_RACE |
| 118 | docker build $(DOCKER_BUILD_ARGS) --target=dev --build-arg CGO_PARAMETER=1 --build-arg EXTRA_GO_BUILD_TAGS="-race" -t ${ADAPTER_IMAGENAME}-rd -f docker/Dockerfile.openonu . |
Holger Hildebrandt | 6999fe5 | 2021-02-11 11:49:05 +0000 | [diff] [blame] | 119 | endif |
Holger Hildebrandt | da7758b | 2020-03-16 11:30:03 +0000 | [diff] [blame] | 120 | |
Joey Armstrong | 7f9c4df | 2022-12-26 19:39:59 -0500 | [diff] [blame] | 121 | ## ----------------------------------------------------------------------- |
| 122 | ## ----------------------------------------------------------------------- |
David K. Bainbridge | ee01bc4 | 2021-04-06 17:38:20 +0000 | [diff] [blame] | 123 | docker-push: ## Push the docker images to an external repository |
Holger Hildebrandt | da7758b | 2020-03-16 11:30:03 +0000 | [diff] [blame] | 124 | docker push ${ADAPTER_IMAGENAME} |
Holger Hildebrandt | 6999fe5 | 2021-02-11 11:49:05 +0000 | [diff] [blame] | 125 | ifdef BUILD_PROFILED |
| 126 | docker push ${ADAPTER_IMAGENAME}-profile |
| 127 | endif |
David K. Bainbridge | 740ca85 | 2021-04-15 00:23:35 +0000 | [diff] [blame] | 128 | ifdef BUILD_RACE |
| 129 | docker push ${ADAPTER_IMAGENAME}-rd |
| 130 | endif |
Holger Hildebrandt | da7758b | 2020-03-16 11:30:03 +0000 | [diff] [blame] | 131 | |
Joey Armstrong | 7f9c4df | 2022-12-26 19:39:59 -0500 | [diff] [blame] | 132 | ## ----------------------------------------------------------------------- |
| 133 | ## ----------------------------------------------------------------------- |
David K. Bainbridge | ee01bc4 | 2021-04-06 17:38:20 +0000 | [diff] [blame] | 134 | docker-kind-load: ## Load docker images into a KinD cluster |
Holger Hildebrandt | da7758b | 2020-03-16 11:30:03 +0000 | [diff] [blame] | 135 | @if [ "`kind get clusters | grep voltha-$(TYPE)`" = '' ]; then echo "no voltha-$(TYPE) cluster found" && exit 1; fi |
| 136 | kind load docker-image ${ADAPTER_IMAGENAME} --name=voltha-$(TYPE) --nodes $(shell kubectl get nodes --template='{{range .items}}{{.metadata.name}},{{end}}' | sed 's/,$$//') |
| 137 | |
Joey Armstrong | 7f9c4df | 2022-12-26 19:39:59 -0500 | [diff] [blame] | 138 | ## ----------------------------------------------------------------------- |
Holger Hildebrandt | da7758b | 2020-03-16 11:30:03 +0000 | [diff] [blame] | 139 | ## lint and unit tests |
Joey Armstrong | 7f9c4df | 2022-12-26 19:39:59 -0500 | [diff] [blame] | 140 | ## ----------------------------------------------------------------------- |
David K. Bainbridge | ee01bc4 | 2021-04-06 17:38:20 +0000 | [diff] [blame] | 141 | lint-dockerfile: ## Perform static analysis on Dockerfile |
Holger Hildebrandt | da7758b | 2020-03-16 11:30:03 +0000 | [diff] [blame] | 142 | @echo "Running Dockerfile lint check ..." |
| 143 | @${HADOLINT} $$(find . -name "Dockerfile.*") |
| 144 | @echo "Dockerfile lint check OK" |
| 145 | |
Joey Armstrong | 7f9c4df | 2022-12-26 19:39:59 -0500 | [diff] [blame] | 146 | ## ----------------------------------------------------------------------- |
| 147 | ## ----------------------------------------------------------------------- |
David K. Bainbridge | ee01bc4 | 2021-04-06 17:38:20 +0000 | [diff] [blame] | 148 | lint-style: ## Perform lint style checks on source code |
Holger Hildebrandt | da7758b | 2020-03-16 11:30:03 +0000 | [diff] [blame] | 149 | @echo "Running style check..." |
| 150 | @gofmt_out="$$(${GOFMT} -l $$(find . -name '*.go' -not -path './vendor/*'))" ;\ |
| 151 | if [ ! -z "$$gofmt_out" ]; then \ |
| 152 | echo "$$gofmt_out" ;\ |
Joey Armstrong | 1b6902d | 2024-01-02 15:43:57 -0500 | [diff] [blame] | 153 | echo "Style check failed on one or more files ^, run 'go fmt -s -e -w' to fix." ;\ |
Holger Hildebrandt | da7758b | 2020-03-16 11:30:03 +0000 | [diff] [blame] | 154 | exit 1 ;\ |
| 155 | fi |
| 156 | @echo "Style check OK" |
| 157 | |
Joey Armstrong | 7f9c4df | 2022-12-26 19:39:59 -0500 | [diff] [blame] | 158 | ## ----------------------------------------------------------------------- |
| 159 | ## ----------------------------------------------------------------------- |
David K. Bainbridge | ee01bc4 | 2021-04-06 17:38:20 +0000 | [diff] [blame] | 160 | lint-sanity: ## Perform basic code checks on source |
Holger Hildebrandt | da7758b | 2020-03-16 11:30:03 +0000 | [diff] [blame] | 161 | @echo "Running sanity check..." |
| 162 | @${GO} vet -mod=vendor ./... |
| 163 | @echo "Sanity check OK" |
| 164 | |
Joey Armstrong | 7f9c4df | 2022-12-26 19:39:59 -0500 | [diff] [blame] | 165 | ## ----------------------------------------------------------------------- |
| 166 | ## ----------------------------------------------------------------------- |
David K. Bainbridge | ee01bc4 | 2021-04-06 17:38:20 +0000 | [diff] [blame] | 167 | lint-mod: ## Verify the Go dependencies |
Joey Armstrong | 7f9c4df | 2022-12-26 19:39:59 -0500 | [diff] [blame] | 168 | $(HIDE)echo "Running dependency check..." |
| 169 | $(HIDE)$(GO) mod verify |
| 170 | $(HIDE)echo "Dependency check OK. Running vendor check..." |
| 171 | $(HIDE)git status > /dev/null |
| 172 | $(HIDE)git diff-index --quiet HEAD -- go.mod go.sum vendor || (echo "ERROR: Staged or modified files must be committed before running this test" && echo "`git status`" && exit 1) |
| 173 | |
Joey Armstrong | a75baed | 2023-11-30 09:48:11 -0500 | [diff] [blame] | 174 | $(HIDE)$(MAKE) --no-print-directory detect-local-edits |
| 175 | |
| 176 | $(HIDE)$(MAKE) --no-print-directory mod-update |
| 177 | |
Joey Armstrong | 7f9c4df | 2022-12-26 19:39:59 -0500 | [diff] [blame] | 178 | $(HIDE)git status > /dev/null |
| 179 | $(HIDE)git diff-index --quiet HEAD -- go.mod go.sum vendor || (echo "ERROR: Modified files detected after running go mod tidy / go mod vendor" && echo "`git status`" && exit 1) |
Holger Hildebrandt | da7758b | 2020-03-16 11:30:03 +0000 | [diff] [blame] | 180 | |
Joey Armstrong | 7f9c4df | 2022-12-26 19:39:59 -0500 | [diff] [blame] | 181 | $(MAKE) --no-print-directory detect-local-edits |
| 182 | $(HIDE)echo "Vendor check OK." |
| 183 | |
| 184 | ## --------------------------------------------------------------------- |
| 185 | ## Intent: Determine if sandbox contains locally modified files |
| 186 | ## --------------------------------------------------------------------- |
| 187 | clean-tree := git status --porcelain |
| 188 | detect-local-edits: |
| 189 | $(HIDE)[[ `$(clean-tree)` == "" ]] || (echo "ERROR: Untracked files detected, commit or remove to continue" && echo "`git status`" && exit 1) |
| 190 | |
| 191 | ## ----------------------------------------------------------------------- |
| 192 | ## ----------------------------------------------------------------------- |
Joey Armstrong | e8c091f | 2023-01-17 16:56:26 -0500 | [diff] [blame] | 193 | lint: local-lib-go lint-style lint-sanity lint-mod lint-dockerfile |
Holger Hildebrandt | da7758b | 2020-03-16 11:30:03 +0000 | [diff] [blame] | 194 | |
Joey Armstrong | 7f9c4df | 2022-12-26 19:39:59 -0500 | [diff] [blame] | 195 | ## ----------------------------------------------------------------------- |
| 196 | ## ----------------------------------------------------------------------- |
Joey Armstrong | 1b6902d | 2024-01-02 15:43:57 -0500 | [diff] [blame] | 197 | results-dir := ./tests/results |
| 198 | coverage-stem := $(results-dir)/go-test-coverage |
| 199 | results-stem := $(results-dir)/go-test-results |
| 200 | |
David K. Bainbridge | ee01bc4 | 2021-04-06 17:38:20 +0000 | [diff] [blame] | 201 | test: lint ## Run unit tests |
Joey Armstrong | 1b6902d | 2024-01-02 15:43:57 -0500 | [diff] [blame] | 202 | |
| 203 | $(call banner-enter,Target $@) |
| 204 | @mkdir -p $(results-dir) |
| 205 | $(HIDE)$(if $(LOCAL_FIX_PERMS),chmod o+w "$(results-dir)") |
| 206 | |
| 207 | # Running remotely |
| 208 | ${GO} test -mod=vendor -v -coverprofile $(coverage-stem).out -covermode count ./... 2>&1 \ |
| 209 | | tee $(results-stem).out ;\ |
Holger Hildebrandt | da7758b | 2020-03-16 11:30:03 +0000 | [diff] [blame] | 210 | RETURN=$$? ;\ |
Joey Armstrong | 1b6902d | 2024-01-02 15:43:57 -0500 | [diff] [blame] | 211 | ${GO_JUNIT_REPORT} < $(results-stem).out > $(results-stem).xml ;\ |
| 212 | ${GOCOVER_COBERTURA} < $(coverage-stem).out > $(coverage-stem).xml ;\ |
Holger Hildebrandt | da7758b | 2020-03-16 11:30:03 +0000 | [diff] [blame] | 213 | exit $$RETURN |
| 214 | |
Joey Armstrong | 1b6902d | 2024-01-02 15:43:57 -0500 | [diff] [blame] | 215 | $(HIDE)$(if $(LOCAL_FIX_PERMS),chmod o-w "$(results-dir)") |
| 216 | $(call banner-enter,Target $@) |
| 217 | |
Joey Armstrong | 7f9c4df | 2022-12-26 19:39:59 -0500 | [diff] [blame] | 218 | ## ----------------------------------------------------------------------- |
| 219 | ## ----------------------------------------------------------------------- |
David K. Bainbridge | ee01bc4 | 2021-04-06 17:38:20 +0000 | [diff] [blame] | 220 | sca: ## Runs static code analysis with the golangci-lint tool |
Holger Hildebrandt | da7758b | 2020-03-16 11:30:03 +0000 | [diff] [blame] | 221 | @mkdir -p ./sca-report |
| 222 | @echo "Running static code analysis..." |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 223 | @${GOLANGCI_LINT} run --deadline=6m --out-format junit-xml ./... | tee ./sca-report/sca-report.xml |
Holger Hildebrandt | da7758b | 2020-03-16 11:30:03 +0000 | [diff] [blame] | 224 | @echo "Static code analysis OK" |
| 225 | |
Joey Armstrong | 7f9c4df | 2022-12-26 19:39:59 -0500 | [diff] [blame] | 226 | ## ----------------------------------------------------------------------- |
| 227 | ## ----------------------------------------------------------------------- |
David K. Bainbridge | ee01bc4 | 2021-04-06 17:38:20 +0000 | [diff] [blame] | 228 | clean: distclean ## Removes any local filesystem artifacts generated by a build |
Holger Hildebrandt | da7758b | 2020-03-16 11:30:03 +0000 | [diff] [blame] | 229 | |
Joey Armstrong | 7f9c4df | 2022-12-26 19:39:59 -0500 | [diff] [blame] | 230 | ## ----------------------------------------------------------------------- |
| 231 | ## ----------------------------------------------------------------------- |
David K. Bainbridge | ee01bc4 | 2021-04-06 17:38:20 +0000 | [diff] [blame] | 232 | distclean: ## Removes any local filesystem artifacts generated by a build or test run |
Joey Armstrong | 7f9c4df | 2022-12-26 19:39:59 -0500 | [diff] [blame] | 233 | $(RM) -r ./sca-report |
Holger Hildebrandt | da7758b | 2020-03-16 11:30:03 +0000 | [diff] [blame] | 234 | |
Joey Armstrong | 7f9c4df | 2022-12-26 19:39:59 -0500 | [diff] [blame] | 235 | ## ----------------------------------------------------------------------- |
| 236 | ## ----------------------------------------------------------------------- |
Joey Armstrong | a75baed | 2023-11-30 09:48:11 -0500 | [diff] [blame] | 237 | .PHONY: mod-update |
| 238 | mod-update: mod-tidy mod-vendor |
| 239 | |
| 240 | ## ----------------------------------------------------------------------- |
| 241 | ## ----------------------------------------------------------------------- |
| 242 | .PHONY: mod-tidy |
| 243 | mod-tidy : |
| 244 | $(call banner-enter,Target $@) |
Holger Hildebrandt | da7758b | 2020-03-16 11:30:03 +0000 | [diff] [blame] | 245 | ${GO} mod tidy |
Joey Armstrong | a75baed | 2023-11-30 09:48:11 -0500 | [diff] [blame] | 246 | $(call banner-leave,Target $@) |
| 247 | |
| 248 | ## ----------------------------------------------------------------------- |
| 249 | ## ----------------------------------------------------------------------- |
| 250 | .PHONY: mod-vendor |
| 251 | mod-vendor : mod-tidy |
| 252 | mod-vendor : |
| 253 | $(call banner-enter,Target $@) |
| 254 | $(if $(LOCAL_FIX_PERMS),chmod o+w $(CURDIR)) |
Holger Hildebrandt | da7758b | 2020-03-16 11:30:03 +0000 | [diff] [blame] | 255 | ${GO} mod vendor |
Joey Armstrong | a75baed | 2023-11-30 09:48:11 -0500 | [diff] [blame] | 256 | $(if $(LOCAL_FIX_PERMS),chmod o-w $(CURDIR)) |
| 257 | $(call banner-leave,Target $@) |
David K. Bainbridge | ee01bc4 | 2021-04-06 17:38:20 +0000 | [diff] [blame] | 258 | |
Joey Armstrong | 1b6902d | 2024-01-02 15:43:57 -0500 | [diff] [blame] | 259 | ## ----------------------------------------------------------------------- |
| 260 | ## For each makefile target, add ## <description> on the target line and it will be listed by 'make help' |
| 261 | ## ----------------------------------------------------------------------- |
| 262 | ## [TODO] Replace with simple printf(s), awk logic confused by double-colons |
| 263 | ## ----------------------------------------------------------------------- |
Joey Armstrong | 7f9c4df | 2022-12-26 19:39:59 -0500 | [diff] [blame] | 264 | help :: ## Print help for each Makefile target |
David K. Bainbridge | ee01bc4 | 2021-04-06 17:38:20 +0000 | [diff] [blame] | 265 | @echo |
Joey Armstrong | 7f9c4df | 2022-12-26 19:39:59 -0500 | [diff] [blame] | 266 | @grep --no-filename '^[[:alpha:]_-]*:.* ##' $(MAKEFILE_LIST) \ |
| 267 | | sort \ |
| 268 | | awk 'BEGIN {FS=":.* ## "}; {printf "%-25s : %s\n", $$1, $$2};' |
Joey Armstrong | 1b6902d | 2024-01-02 15:43:57 -0500 | [diff] [blame] | 269 | @printf '\n' |
| 270 | @printf ' %-33.33s %s\n' 'mod-update' \ |
| 271 | 'Alias for makefile targets mod-tidy + mod-vendor |
| 272 | @printf ' %-33.33s %s\n' 'mod-tidy' \ |
| 273 | 'Refresh packages, update go.mod and go.sum' |
| 274 | @printf ' %-33.33s %s\n' 'mod-vendor' \ |
| 275 | 'Update go package dependencies beneath vendor'. |
Joey Armstrong | 7f9c4df | 2022-12-26 19:39:59 -0500 | [diff] [blame] | 276 | |
| 277 | # [EOF] |