Joey Armstrong | 99a72d0 | 2023-06-09 10:26:42 -0400 | [diff] [blame] | 1 | # -*- makefile -*- |
| 2 | # ----------------------------------------------------------------------- |
Joey Armstrong | 6f63edf | 2024-01-12 11:30:08 -0500 | [diff] [blame] | 3 | # Copyright 2017-2024 Open Networking Foundation (ONF) and the ONF Contributors |
Joey Armstrong | 99a72d0 | 2023-06-09 10:26:42 -0400 | [diff] [blame] | 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 | |
| 20 | VOLTHA_TOOLS_VERSION ?= 2.4.0 |
| 21 | |
| 22 | # --------------------------- |
| 23 | # Macros: command refactoring |
| 24 | # --------------------------- |
| 25 | docker-iam ?= --user $$(id -u):$$(id -g)# # override for local use |
| 26 | docker-run = docker run --rm $(docker-iam)# # Docker command stem |
| 27 | docker-run-is = $(docker-run) $(is-stdin) # Attach streams when interactive |
| 28 | docker-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 | # ----------------------------------------------------------------------- |
| 34 | is-stdin = $(shell test -t 0 && { echo '--interactive'; }) |
| 35 | is-stdin += --tty |
| 36 | |
| 37 | voltha-protos-v5 ?= /go/src/github.com/opencord/voltha-protos/v5 |
| 38 | |
| 39 | # Docker volume mounts: container:/app/release <=> localhost:{pwd}/release |
| 40 | vee-golang = -v gocache-${VOLTHA_TOOLS_VERSION}:/go/pkg |
| 41 | vee-citools = voltha/voltha-ci-tools:${VOLTHA_TOOLS_VERSION} |
| 42 | |
| 43 | # --------------- |
| 44 | # Tool Containers |
| 45 | # --------------- |
| 46 | docker-go-stem = $(docker-run-app) -v gocache:/.cache $(vee-golang) $(vee-citools)-golang |
| 47 | |
| 48 | # Usage: GO := $(call get-docker-go,./my.env.temp) |
| 49 | get-docker-go = $(docker-go-stem) go |
| 50 | GO ?= $(call get-docker-go) |
| 51 | |
| 52 | # Usage: GO_SH := $(call get-docker-go-sh,./my.env.temp) |
| 53 | get-docker-go-sh = $(docker-go-stem) $(if $(1),--env-file $(1)) sh -c |
| 54 | GO_SH ?= $(call get-docker-go-sh,./my.env.temp) |
| 55 | |
| 56 | # Usage: PROTOC := $(call get-docker-protoc) |
| 57 | get-docker-protoc = $(docker-run-app) $(vee-citools)-protoc protoc |
| 58 | PROTOC ?= $(call get-docker-protoc) |
| 59 | |
| 60 | # get-docker-protoc-sh = $(strip ) |
| 61 | PROTOC_SH = $(docker-run-is) |
| 62 | ifdef voltha-protos-v5 |
| 63 | PROTOC_SH += -v ${CURDIR}:$(voltha-protos-v5) |
| 64 | PROTOC_SH += --workdir=$(voltha-protos-v5) |
| 65 | endif |
| 66 | PROTOC_SH += $(vee-citools)-protoc sh -c |
| 67 | |
| 68 | $(if $(DEBUG),$(warning LEAVE)) |
| 69 | |
| 70 | # [EOF] |