Joey Armstrong | 04cdd9f | 2023-06-09 15:18:23 -0400 | [diff] [blame] | 1 | # -*- makefile -*- |
| 2 | # ----------------------------------------------------------------------- |
Joey Armstrong | 9fadcbe | 2024-01-17 19:00:37 -0500 | [diff] [blame] | 3 | # Copyright 2017-2024 Open Networking Foundation (ONF) and the ONF Contributors |
Joey Armstrong | 04cdd9f | 2023-06-09 15:18:23 -0400 | [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.d |
| 16 | # ----------------------------------------------------------------------- |
| 17 | |
| 18 | $(if $(DEBUG),$(warning ENTER)) |
| 19 | |
| 20 | VOLTHA_TOOLS_VERSION ?= 2.4.0 |
| 21 | |
| 22 | # --------------------------- |
| 23 | # Macros: command refactoring |
| 24 | # --------------------------- |
| 25 | docker-iam ?= --user $$(id -u):$$(id -g)# # override for local use |
| 26 | docker-run = docker run --rm $(docker-iam)# # Docker command stem |
| 27 | docker-run-is = $(docker-run) $(is-stdin)# # Attach streams when interactive |
| 28 | docker-run-app = $(docker-run-is) -v ${CURDIR}:/app# # w/filesystem mount |
| 29 | |
| 30 | # ----------------------------------------------------------------------- |
| 31 | # --interactive: Attach streams when stdout (fh==0) defined |
| 32 | # --tty : Always create a pseudo-tty else jenkins:docker is silent |
| 33 | # ----------------------------------------------------------------------- |
| 34 | is-stdin = $(shell test -t 0 && { echo '--interactive'; }) |
| 35 | is-stdin += --tty |
| 36 | |
| 37 | voltha-protos-v5 ?= /go/src/github.com/opencord/voltha-protos/v5 |
| 38 | |
| 39 | # Docker volume mounts: container:/app/release <=> localhost:{pwd}/release |
| 40 | vee-golang = -v gocache-${VOLTHA_TOOLS_VERSION}:/go/pkg |
| 41 | vee-citools = voltha/voltha-ci-tools:${VOLTHA_TOOLS_VERSION} |
| 42 | |
| 43 | # --------------- |
| 44 | # Tool Containers |
| 45 | # --------------- |
| 46 | docker-go-stem = $(docker-run-app) -v gocache:/.cache $(vee-golang) $(vee-citools)-golang |
| 47 | |
| 48 | # Usage: GO := $(call get-docker-go,./my.env.temp) |
| 49 | get-docker-go = $(docker-go-stem) go |
| 50 | GO ?= $(call get-docker-go) |
| 51 | |
| 52 | # Usage: GO_SH := $(call get-docker-go-sh,./my.env.temp) |
| 53 | get-docker-go-sh = $(docker-go-stem) $(if $(1),--env-file $(1)) sh -c |
| 54 | GO_SH ?= $(call get-docker-go-sh,./my.env.temp) |
| 55 | |
| 56 | # Usage: PROTOC := $(call get-docker-protoc) |
| 57 | get-docker-protoc = $(docker-run-app) $(vee-citools)-protoc protoc |
| 58 | PROTOC ?= $(call get-docker-protoc) |
| 59 | |
| 60 | # get-docker-protoc-sh = $(strip ) |
| 61 | PROTOC_SH = $(docker-run-is) |
| 62 | ifdef voltha-protos-v5 |
| 63 | PROTOC_SH += -v ${CURDIR}:$(voltha-protos-v5) |
| 64 | PROTOC_SH += --workdir=$(voltha-protos-v5) |
| 65 | endif |
| 66 | PROTOC_SH += $(vee-citools)-protoc sh -c |
| 67 | |
| 68 | # Usage: GO_JUNIT_REPORT := $(call get-docker-go-junit-repo) |
| 69 | # get-docker-go-junit-repo = $(docker-run-app) $(vee-citools)-go-junit-report go-junit-report |
| 70 | # GO_JUNIT_REPORT ?= $(call get-docker-go-junit-repo) |
| 71 | |
| 72 | # Usage: GOCOVER_COBERTURA := $(call get-docker-gocover-cobertura) |
| 73 | # get-docker-gocover-cobertura = $(docker-run-app)/src/github.com/opencord/voltha-openolt-adapter $(vee-citools)-gocover-cobertura gocover-cobertura |
| 74 | # GOCOVER_COBERTURA ?= $(call get-docker-gocover-cobertura) |
| 75 | |
| 76 | GO_JUNIT_REPORT = $(docker-run) -v ${CURDIR}:/app -i $(vee-citools)-go-junit-report go-junit-report |
| 77 | GOCOVER_COBERTURA = $(docker-run) -v ${CURDIR}:/app/src/github.com/opencord/voltha-openolt-adapter -i $(vee-citools)-gocover-cobertura gocover-cobertura |
| 78 | |
| 79 | |
| 80 | get-golangci-lint = $(docker-run-app) -v gocache:/.cache $(vee-golang) $(vee-citools)-golangci-lint golangci-lint |
| 81 | GOLANGCI_LINT ?= $(call get-golangci-lint) |
| 82 | |
| 83 | get-docker-hadolint = $(docker-run-app) $(vee-citools)-hadolint hadolint |
| 84 | HADOLINT ?= $(call get-docker-hadolint) |
| 85 | |
| 86 | $(if $(DEBUG),$(warning LEAVE)) |
| 87 | |
| 88 | # [EOF] |