Joey Armstrong | f863afb | 2023-03-29 12:08:38 -0400 | [diff] [blame] | 1 | # -*- makefile -*- |
| 2 | # ----------------------------------------------------------------------- |
| 3 | # Copyright 2019-2023 Open Networking Foundation |
| 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: |
| 22 | ## o Generate volctl binaries in a docker container container |
| 23 | ## o Copy container:/apps/release to localhost:{pwd}/release |
| 24 | ## ----------------------------------------------------------------------- |
Joey Armstrong | 9c6e808 | 2023-04-03 12:19:06 -0400 | [diff] [blame] | 25 | ## [TODO] Replace ${GO_SH} $(quote-single) .. with $(call quoted,cmd-text) |
Joey Armstrong | f863afb | 2023-03-29 12:08:38 -0400 | [diff] [blame] | 26 | ## ----------------------------------------------------------------------- |
| 27 | release-build : |
| 28 | |
| 29 | @echo |
| 30 | @echo "** -----------------------------------------------------------------------" |
| 31 | @echo "** $(MAKE): processing target [$@]" |
| 32 | @echo "** Sandbox: $(shell /bin/pwd)" |
| 33 | @echo "** -----------------------------------------------------------------------" |
| 34 | |
Joey Armstrong | 9c6e808 | 2023-04-03 12:19:06 -0400 | [diff] [blame] | 35 | # [DEBUG] Yes this will take a while but where-4-art-thou-golang-in-docker-image-(?) |
| 36 | @echo -e "\n** golang interpreter" |
Joey Armstrong | dd2a078 | 2023-04-04 09:29:48 -0400 | [diff] [blame] | 37 | # find '/usr/local' '/go' '/usr/bin' '/bin' -name 'go' ! -type d -print; |
Joey Armstrong | 9088c89 | 2023-04-04 08:07:23 -0400 | [diff] [blame] | 38 | # -${GO_SH} $(quote-single) find / -name 'go' ! -type d -print $(quote-single) |
Joey Armstrong | 9c6e808 | 2023-04-03 12:19:06 -0400 | [diff] [blame] | 39 | |
Joey Armstrong | 9088c89 | 2023-04-04 08:07:23 -0400 | [diff] [blame] | 40 | -$(HIDE)${GO_SH} $(call quoted,which$(space)-a$(space)go) |
| 41 | -$(HIDE)${GO_SH} $(call quoted,go$(space)version) |
Joey Armstrong | f863afb | 2023-03-29 12:08:38 -0400 | [diff] [blame] | 42 | |
| 43 | @echo -e "\n** Create filesystem target for docker volume: $(RELEASE_DIR)" |
| 44 | $(RM) -r "./$(RELEASE_DIR)" |
| 45 | mkdir -vp "$(RELEASE_DIR)" |
| 46 | |
Joey Armstrong | 9c6e808 | 2023-04-03 12:19:06 -0400 | [diff] [blame] | 47 | $(MAKE) docker-debug |
| 48 | |
Joey Armstrong | f863afb | 2023-03-29 12:08:38 -0400 | [diff] [blame] | 49 | @echo |
Joey Armstrong | 9c6e808 | 2023-04-03 12:19:06 -0400 | [diff] [blame] | 50 | @echo '** -----------------------------------------------------------------------' |
Joey Armstrong | dd2a078 | 2023-04-04 09:29:48 -0400 | [diff] [blame] | 51 | @echo '** Filesystem: docker-container::/app (wanted: release/)' |
| 52 | @echo '** -----------------------------------------------------------------------' |
| 53 | ${GO_SH} $(quote-single)find /app \( -name ".git" -o -name "vendor" -o -name "makefiles" -o -name "internal" -o -name "pkg" \) -prune -o -print$(quote-single) |
| 54 | @echo |
| 55 | @echo '** /app/release permissions' |
| 56 | # ${GO_SH} $(quote-single)umask 022 && chmod 700 /app/release $(quote-single) |
| 57 | ${GO_SH} $(quote-single)/bin/ls -ld /app/release $(quote-single) |
| 58 | |
| 59 | @echo |
| 60 | @echo '** -----------------------------------------------------------------------' |
Joey Armstrong | f863afb | 2023-03-29 12:08:38 -0400 | [diff] [blame] | 61 | @echo '** Docker builds bins into mounted filesystem:' |
| 62 | @echo '** container:/app/relase' |
| 63 | @echo '** localhost:{pwd}/release' |
Joey Armstrong | 9c6e808 | 2023-04-03 12:19:06 -0400 | [diff] [blame] | 64 | @echo '** -----------------------------------------------------------------------' |
Joey Armstrong | dd2a078 | 2023-04-04 09:29:48 -0400 | [diff] [blame] | 65 | |
| 66 | # NOTE: Use double quotes in echo strings else command breakage |
Joey Armstrong | 173f255 | 2023-04-04 08:44:21 -0400 | [diff] [blame] | 67 | ${GO_SH} $(quote-single) \ |
Joey Armstrong | dd2a078 | 2023-04-04 09:29:48 -0400 | [diff] [blame] | 68 | echo ;\ |
| 69 | echo "build: ENTER" ;\ |
Joey Armstrong | f863afb | 2023-03-29 12:08:38 -0400 | [diff] [blame] | 70 | set -e -o pipefail; \ |
Joey Armstrong | 9c6e808 | 2023-04-03 12:19:06 -0400 | [diff] [blame] | 71 | set -x ; \ |
Joey Armstrong | f863afb | 2023-03-29 12:08:38 -0400 | [diff] [blame] | 72 | for x in ${RELEASE_OS_ARCH}; do \ |
Joey Armstrong | 9c6e808 | 2023-04-03 12:19:06 -0400 | [diff] [blame] | 73 | echo ;\ |
| 74 | echo "** RELEASE_OS_ARCH: Build arch is $$x"; \ |
Joey Armstrong | f863afb | 2023-03-29 12:08:38 -0400 | [diff] [blame] | 75 | OUT_PATH="$(RELEASE_DIR)/$(RELEASE_NAME)-$(subst -dev,_dev,$(VERSION))-$$x"; \ |
Joey Armstrong | 9c6e808 | 2023-04-03 12:19:06 -0400 | [diff] [blame] | 76 | echo ;\ |
| 77 | echo "** Building: $$OUT_PATH (ENTER)"; \ |
Joey Armstrong | f863afb | 2023-03-29 12:08:38 -0400 | [diff] [blame] | 78 | GOOS=$${x%-*} GOARCH=$${x#*-} go build -mod=vendor -v $(LDFLAGS) -o "$$OUT_PATH" cmd/voltctl/voltctl.go; \ |
Joey Armstrong | 9c6e808 | 2023-04-03 12:19:06 -0400 | [diff] [blame] | 79 | echo "** Building: $$OUT_PATH (LEAVE)"; \ |
Joey Armstrong | dd2a078 | 2023-04-04 09:29:48 -0400 | [diff] [blame] | 80 | done ;\ |
| 81 | echo "build: LEAVE" \ |
Joey Armstrong | 9c6e808 | 2023-04-03 12:19:06 -0400 | [diff] [blame] | 82 | $(quote-single) |
Joey Armstrong | f863afb | 2023-03-29 12:08:38 -0400 | [diff] [blame] | 83 | |
| 84 | @echo |
Joey Armstrong | 9c6e808 | 2023-04-03 12:19:06 -0400 | [diff] [blame] | 85 | @echo "** -----------------------------------------------------------------------" |
Joey Armstrong | f863afb | 2023-03-29 12:08:38 -0400 | [diff] [blame] | 86 | @echo '** Post-build, files to release' |
Joey Armstrong | 9c6e808 | 2023-04-03 12:19:06 -0400 | [diff] [blame] | 87 | @echo "** -----------------------------------------------------------------------" |
Joey Armstrong | 9088c89 | 2023-04-04 08:07:23 -0400 | [diff] [blame] | 88 | -find "$(RELEASE_DIR)" ! -type d -print |
Joey Armstrong | 9c6e808 | 2023-04-03 12:19:06 -0400 | [diff] [blame] | 89 | @echo |
| 90 | |
| 91 | ## ----------------------------------------------------------------------- |
| 92 | ## Intent: Why is go not found reported after |
| 93 | ## ----------------------------------------------------------------------- |
| 94 | docker-debug: |
| 95 | |
| 96 | @echo |
| 97 | @echo "** -----------------------------------------------------------------------" |
| 98 | @echo "** [TARGET] $@" |
| 99 | @echo "** -----------------------------------------------------------------------" |
| 100 | |
| 101 | @echo |
| 102 | docker images |
| 103 | |
| 104 | @echo |
| 105 | docker ps --all |
| 106 | |
| 107 | @echo |
Joey Armstrong | f863afb | 2023-03-29 12:08:38 -0400 | [diff] [blame] | 108 | |
| 109 | ## ----------------------------------------------------------------------- |
| 110 | ## ----------------------------------------------------------------------- |
| 111 | clean :: |
| 112 | $(RM) -r "./$(RELEASE_DIR)" |
| 113 | |
| 114 | ## ----------------------------------------------------------------------- |
| 115 | ## ----------------------------------------------------------------------- |
| 116 | help :: |
| 117 | @echo ' release-build Cross-compile binaries into a docker mounted filesystem' |
| 118 | |
| 119 | $(if $(DEBUG),$(warning LEAVE)) |
| 120 | |
| 121 | # [EOF] |