blob: 20e409b91b2274d0f3fa279920e20aa1dc9d9bdb [file] [log] [blame]
Joey Armstrong99a72d02023-06-09 10:26:42 -04001# -*- makefile -*-
2# -----------------------------------------------------------------------
Joey Armstrong6f63edf2024-01-12 11:30:08 -05003# Copyright 2017-2024 Open Networking Foundation (ONF) and the ONF Contributors
Joey Armstrong99a72d02023-06-09 10:26:42 -04004#
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
22# ---------------------------
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
27docker-run-is = $(docker-run) $(is-stdin) # Attach streams when interactive
28docker-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
68$(if $(DEBUG),$(warning LEAVE))
69
70# [EOF]