blob: a56a85ff589a5fa6b533c25fb18498d7e3226244 [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
22include $(MAKEDIR)/docker/versions.mk
23
24# ---------------------------
25# Macros: command refactoring
26# ---------------------------
27docker-iam ?= --user $$(id -u):$$(id -g)# # override for local use
28docker-run = docker run --rm $(docker-iam)# # Docker command stem
29docker-run-is = $(docker-run) $(is-stdin) # Attach streams when interactive
30docker-run-app = $(docker-run-is) -v ${CURDIR}:/app# # w/filesystem mount
31
32# -----------------------------------------------------------------------
33# --interactive: Attach streams when stdout (fh==0) defined
34# --tty : Always create a pseudo-tty else jenkins:docker is silent
35# -----------------------------------------------------------------------
36is-stdin = $(shell test -t 0 && { echo '--interactive'; })
37is-stdin += --tty
38
39voltha-protos-v5 ?= /go/src/github.com/opencord/voltha-protos/v5
40
41# Docker volume mounts: container:/app/release <=> localhost:{pwd}/release
42vee-golang = -v gocache-${VOLTHA_TOOLS_VERSION}:/go/pkg
43vee-citools = voltha/voltha-ci-tools:${VOLTHA_TOOLS_VERSION}
44
45# ---------------
46# Tool Containers
47# ---------------
48docker-go-stem = $(docker-run-app) -v gocache:/.cache $(vee-golang) $(vee-citools)-golang
49
50# Usage: GO := $(call get-docker-go,./my.env.temp)
51get-docker-go = $(docker-go-stem) go
52GO ?= $(call get-docker-go)
53
54# Usage: GO_SH := $(call get-docker-go-sh,./my.env.temp)
55get-docker-go-sh = $(docker-go-stem) $(if $(1),--env-file $(1)) sh -c
56GO_SH ?= $(call get-docker-go-sh,./my.env.temp)
57
58# Usage: PROTOC := $(call get-docker-protoc)
59get-docker-protoc = $(docker-run-app) $(vee-citools)-protoc protoc
60PROTOC ?= $(call get-docker-protoc)
61
62# get-docker-protoc-sh = $(strip )
63PROTOC_SH = $(docker-run-is)
64ifdef voltha-protos-v5
65 PROTOC_SH += -v ${CURDIR}:$(voltha-protos-v5)
66 PROTOC_SH += --workdir=$(voltha-protos-v5)
67endif
68PROTOC_SH += $(vee-citools)-protoc sh -c
69
70$(if $(DEBUG),$(warning LEAVE))
71
72# [EOF]