blob: 3326b27251d06f609f4285ae10d367e9dd2ca9b5 [file] [log] [blame]
Joey Armstrong367d76b2023-06-08 17:16:46 -04001# -*- makefile -*-
2# -----------------------------------------------------------------------
3# Copyright 2017-2023 Open Networking Foundation (ONF) and the ONF Contributors
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
20VOLTHA_TOOLS_VERSION ?= 2.4.0
21
Joey Armstrong367d76b2023-06-08 17:16:46 -040022# ---------------------------
23# Macros: command refactoring
24# ---------------------------
25docker-iam ?= --user $$(id -u):$$(id -g)# # override for local use
26docker-run = docker run --rm $(docker-iam)# # Docker command stem
Joey Armstrong393daca2023-07-06 08:47:54 -040027docker-run-is = $(docker-run) $(is-stdin)# # Attach streams when interactive
Joey Armstrong367d76b2023-06-08 17:16:46 -040028docker-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# -----------------------------------------------------------------------
34is-stdin = $(shell test -t 0 && { echo '--interactive'; })
35is-stdin += --tty
36
37voltha-protos-v5 ?= /go/src/github.com/opencord/voltha-protos/v5
38
39# Docker volume mounts: container:/app/release <=> localhost:{pwd}/release
40vee-golang = -v gocache-${VOLTHA_TOOLS_VERSION}:/go/pkg
41vee-citools = voltha/voltha-ci-tools:${VOLTHA_TOOLS_VERSION}
42
43# ---------------
44# Tool Containers
45# ---------------
46docker-go-stem = $(docker-run-app) -v gocache:/.cache $(vee-golang) $(vee-citools)-golang
47
48# Usage: GO := $(call get-docker-go,./my.env.temp)
49get-docker-go = $(docker-go-stem) go
50GO ?= $(call get-docker-go)
51
52# Usage: GO_SH := $(call get-docker-go-sh,./my.env.temp)
53get-docker-go-sh = $(docker-go-stem) $(if $(1),--env-file $(1)) sh -c
54GO_SH ?= $(call get-docker-go-sh,./my.env.temp)
55
56# Usage: PROTOC := $(call get-docker-protoc)
57get-docker-protoc = $(docker-run-app) $(vee-citools)-protoc protoc
58PROTOC ?= $(call get-docker-protoc)
59
60# get-docker-protoc-sh = $(strip )
61PROTOC_SH = $(docker-run-is)
62ifdef voltha-protos-v5
63 PROTOC_SH += -v ${CURDIR}:$(voltha-protos-v5)
64 PROTOC_SH += --workdir=$(voltha-protos-v5)
65endif
66PROTOC_SH += $(vee-citools)-protoc sh -c
67
Joey Armstrong393daca2023-07-06 08:47:54 -040068# 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
76GO_JUNIT_REPORT = $(docker-run) -v ${CURDIR}:/app -i $(vee-citools)-go-junit-report go-junit-report
77GOCOVER_COBERTURA = $(docker-run) -v ${CURDIR}:/app/src/github.com/opencord/voltha-openolt-adapter -i $(vee-citools)-gocover-cobertura gocover-cobertura
78
79get-golangci-lint = $(docker-run-app) -v gocache:/.cache $(vee-golang) $(vee-citools)-golangci-lint golangci-lint
80GOLANGCI_LINT ?= $(call get-golangci-lint)
81
82get-docker-hadolint = $(docker-run-app) $(vee-citools)-hadolint hadolint
83HADOLINT ?= $(call get-docker-hadolint)
84
Joey Armstrong367d76b2023-06-08 17:16:46 -040085$(if $(DEBUG),$(warning LEAVE))
86
87# [EOF]