blob: 48e20caceff9a6d071becf22da7b5ef2b5f54926 [file] [log] [blame]
Joey Armstrong0205d332023-04-11 17:29:23 -04001# -*- makefile -*-
2# -----------------------------------------------------------------------
Joey Armstrongd26858f2023-07-08 15:52:16 -04003# Copyright 2017-2023 Open Networking Foundation (ONF) and the ONF Contributors
Joey Armstrong0205d332023-04-11 17:29:23 -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
Joey Armstrongd26858f2023-07-08 15:52:16 -040015# limitations under the License.d
Joey Armstrong0205d332023-04-11 17:29:23 -040016# -----------------------------------------------------------------------
Joey Armstronga6890342023-06-01 17:07:51 -040017
Joey Armstrong0205d332023-04-11 17:29:23 -040018$(if $(DEBUG),$(warning ENTER))
19
Joey Armstrongd26858f2023-07-08 15:52:16 -040020VOLTHA_TOOLS_VERSION ?= 2.4.0
Joey Armstrong0205d332023-04-11 17:29:23 -040021
Joey Armstrongd26858f2023-07-08 15:52:16 -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
27docker-run-is = $(docker-run) $(is-stdin) # Attach streams when interactive
28docker-run-app = $(docker-run-is) -v ${CURDIR}:/app# # w/filesystem mount
29is-stdin = $(shell test -t 0 && echo "-it")
Joey Armstrong0205d332023-04-11 17:29:23 -040030
Joey Armstrongd26858f2023-07-08 15:52:16 -040031voltha-protos-v5 ?= /go/src/github.com/opencord/voltha-protos/v5
Joey Armstrong42f4ce62023-06-09 12:56:48 -040032
Joey Armstrongd26858f2023-07-08 15:52:16 -040033# 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}
Joey Armstrong0205d332023-04-11 17:29:23 -040036
Joey Armstrongd26858f2023-07-08 15:52:16 -040037# ---------------
38# Tool Containers
39# ---------------
40docker-go-stem = $(docker-run-app) -v gocache:/.cache $(vee-golang) $(vee-citools)-golang
Joey Armstrong0205d332023-04-11 17:29:23 -040041
Joey Armstrongd26858f2023-07-08 15:52:16 -040042# Usage: GO := $(call get-docker-go,./my.env.temp)
43get-docker-go = $(docker-go-stem) go
44GO ?= $(call get-docker-go)
Joey Armstronga6890342023-06-01 17:07:51 -040045
Joey Armstrongd26858f2023-07-08 15:52:16 -040046# 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
Joey Armstrong0205d332023-04-11 17:29:23 -040061
62$(if $(DEBUG),$(warning LEAVE))
63
Joey Armstrong0205d332023-04-11 17:29:23 -040064# [EOF]