blob: 48e20caceff9a6d071becf22da7b5ef2b5f54926 [file] [log] [blame]
Joey Armstrong86218422023-05-09 12:24:44 -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
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
Joey Armstrongd26858f2023-07-08 15:52:16 -040029is-stdin = $(shell test -t 0 && echo "-it")
Joey Armstrong86218422023-05-09 12:24:44 -040030
31voltha-protos-v5 ?= /go/src/github.com/opencord/voltha-protos/v5
32
33# Docker volume mounts: container:/app/release <=> localhost:{pwd}/release
34vee-golang = -v gocache-${VOLTHA_TOOLS_VERSION}:/go/pkg
35vee-citools = voltha/voltha-ci-tools:${VOLTHA_TOOLS_VERSION}
36
37# ---------------
38# Tool Containers
39# ---------------
40docker-go-stem = $(docker-run-app) -v gocache:/.cache $(vee-golang) $(vee-citools)-golang
41
42# Usage: GO := $(call get-docker-go,./my.env.temp)
43get-docker-go = $(docker-go-stem) go
44GO ?= $(call get-docker-go)
45
46# Usage: GO_SH := $(call get-docker-go-sh,./my.env.temp)
47get-docker-go-sh = $(docker-go-stem) $(if $(1),--env-file $(1)) sh -c
48GO_SH ?= $(call get-docker-go-sh,./my.env.temp)
49
50# Usage: PROTOC := $(call get-docker-protoc)
51get-docker-protoc = $(docker-run-app) $(vee-citools)-protoc protoc
52PROTOC ?= $(call get-docker-protoc)
53
54# get-docker-protoc-sh = $(strip )
55PROTOC_SH = $(docker-run-is)
56ifdef voltha-protos-v5
57 PROTOC_SH += -v ${CURDIR}:$(voltha-protos-v5)
58 PROTOC_SH += --workdir=$(voltha-protos-v5)
59endif
60PROTOC_SH += $(vee-citools)-protoc sh -c
61
62$(if $(DEBUG),$(warning LEAVE))
63
64# [EOF]