Joey Armstrong | 36c9bcd | 2023-04-05 19:05:56 -0400 | [diff] [blame] | 1 | # -*- 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. |
| 16 | # ----------------------------------------------------------------------- |
| 17 | |
| 18 | $(if $(DEBUG),$(warning ENTER)) |
| 19 | |
| 20 | ## ----------------------------------------------------------------------- |
| 21 | ## Intent: Given a hyphen separated list of values return item [n] |
| 22 | ## ----------------------------------------------------------------------- |
| 23 | ## Usage: |
| 24 | ## value := foo-bar-tans-fans |
| 25 | ## tans-val = $(call get-hyphen-field,value,3) |
| 26 | ## ----------------------------------------------------------------------- |
| 27 | get-hyphen-field = $(word $(1),$(subst -,$(space),$(notdir $(2)))) |
| 28 | |
| 29 | ## ----------------------------------------------------------------------- |
| 30 | ## Intent: Construct a parameterized $(GO_SH) command |
| 31 | ## Given: |
| 32 | ## argv[1] Response file containing environment vars passed to docker. |
| 33 | ## Usage: |
| 34 | ## cmd = $(my-go-sh,./env-vars) |
| 35 | ## Debug: view arguments passed |
| 36 | ## make DEBUG=1 |
| 37 | ## ----------------------------------------------------------------------- |
| 38 | my-go-sh=$(strip \ |
| 39 | $(docker-run-app) \ |
| 40 | $(is-stdin) \ |
| 41 | $(if $(1),--env-file $(1)) \ |
| 42 | -v gocache:/.cache \ |
| 43 | $(vee-golang) \ |
| 44 | $(vee-citools)-golang \ |
| 45 | sh -c \ |
| 46 | ) |
| 47 | |
| 48 | ## ----------------------------------------------------------------------- |
| 49 | ## Intent: Derive a list of release platform binaries by name |
| 50 | ## ----------------------------------------------------------------------- |
| 51 | ## Given: |
| 52 | ## $1 (scalar:name) $(RELEASE_BBSIM_NAME) |
| 53 | ## $2 (indirect:arches) $(RELEASE_OS_ARCH) |
| 54 | ## ----------------------------------------------------------------------- |
| 55 | ## Usage: deps = $(call release-gen-deps-name,tool-name,tool-arches) |
| 56 | ## ----------------------------------------------------------------------- |
| 57 | release-gen-deps-name=$(strip \ |
| 58 | \ |
| 59 | $(if $($(1)),$(null),$(error name= is required))\ |
| 60 | $(if $($(2)),$(null),$(error arches= is required))\ |
| 61 | \ |
| 62 | $(foreach name,$($(1)),\ |
| 63 | $(if $(DEBUG),$(info name=$(name)))\ |
| 64 | $(foreach arches,$(2),\ |
| 65 | $(if $(DEBUG),$(info arches=$(arches)))\ |
| 66 | $(foreach arch,$($(arches)),\ |
| 67 | $(if $(DEBUG),$(info arch=$(arch): $(name)-$(arch)))\ |
| 68 | $(name)-$(arch)\ |
| 69 | )\ |
| 70 | ))\ |
| 71 | ) |
| 72 | |
| 73 | ## ----------------------------------------------------------------------- |
| 74 | ## Intent: Derive a list of release binary dependencies |
| 75 | ## ----------------------------------------------------------------------- |
| 76 | ## Returns: |
| 77 | ## release/bbsim-darwin-amd64 |
| 78 | ## release/bbsim-linux-amd64 |
| 79 | ## release/bbsim-windows-amd64 |
| 80 | ## ----------------------------------------------------------------------- |
| 81 | ## Usage: |
| 82 | ## tool-name = bbsim |
| 83 | ## tool-arches = darwin linux windows |
| 84 | ## release-dir = release |
| 85 | ## deps = $(call release-gen-deps,tool-name,tool-arches,release-dir) |
| 86 | ## $(foreach val,$(deps),$(info ** deps=$(val))) |
| 87 | ## ----------------------------------------------------------------------- |
| 88 | release-gen-deps=$(strip \ |
| 89 | \ |
| 90 | $(if $($(1)),$(null),$(error name= is required))\ |
| 91 | $(if $($(2)),$(null),$(error arches= is required))\ |
| 92 | $(if $($(3)),$(null),$(error release-dir= is required))\ |
| 93 | \ |
| 94 | $(if $(DEBUG),$(info release-dir=$(3)))\ |
| 95 | $(foreach release-dir,$($(3)),\ |
| 96 | $(addprefix $(release-dir)/,$(call release-gen-deps-name,$(1),$(2)))\ |
| 97 | )\ |
| 98 | ) |
| 99 | |
| 100 | $(if $(DEBUG),$(warning LEAVE)) |
| 101 | |
| 102 | # [EOF] |