From b4916b48be2d94c8f73a3e2d4e6ef6cd7ee2ed43 Mon Sep 17 00:00:00 2001 From: Nimish <85357445+nimish-ks@users.noreply.github.com> Date: Fri, 8 Nov 2024 03:04:35 +0530 Subject: [PATCH] Add build for armv7 buf binaries (#3450) --- make/buf/scripts/release.bash | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/make/buf/scripts/release.bash b/make/buf/scripts/release.bash index 0d97ae3c12..4d69635ee1 100644 --- a/make/buf/scripts/release.bash +++ b/make/buf/scripts/release.bash @@ -27,6 +27,7 @@ goarch() { x86_64) echo amd64 ;; arm64) echo arm64 ;; aarch64) echo arm64 ;; + armv7) echo arm ;; *) return 1 ;; esac } @@ -83,7 +84,7 @@ mkdir -p "${RELEASE_DIR}" cd "${RELEASE_DIR}" for os in Darwin Linux Windows; do - for arch in x86_64 arm64; do + for arch in x86_64 arm64 armv7; do # our goal is to have the binaries be suffixed with $(uname -s)-$(uname -m) # on mac, this is arm64, on linux, this is aarch64, for historical reasons # this is a hacky way to not have to rewrite this loop (and others below) @@ -100,15 +101,27 @@ for os in Darwin Linux Windows; do buf \ protoc-gen-buf-breaking \ protoc-gen-buf-lint; do - CGO_ENABLED=0 GOOS=$(goos "${os}") GOARCH=$(goarch "${arch}") \ - go build -a -ldflags "-s -w" -trimpath -buildvcs=false -o "${dir}/bin/${binary}${extension}" "${DIR}/cmd/${binary}" + if [ "${arch}" == "armv7" ]; then + if [ "${os}" == "Linux" ]; then + CGO_ENABLED=0 GOOS=$(goos "${os}") GOARCH=$(goarch "${arch}") GOARM=7 \ + go build -a -ldflags "-s -w" -trimpath -buildvcs=false -o "${dir}/bin/${binary}${extension}" "${DIR}/cmd/${binary}" + else + continue + fi + else + CGO_ENABLED=0 GOOS=$(goos "${os}") GOARCH=$(goarch "${arch}") \ + go build -a -ldflags "-s -w" -trimpath -buildvcs=false -o "${dir}/bin/${binary}${extension}" "${DIR}/cmd/${binary}" + fi cp "${dir}/bin/${binary}${extension}" "${binary}-${os}-${arch}${extension}" done done done for os in Darwin Linux Windows; do - for arch in x86_64 arm64; do + for arch in x86_64 arm64 armv7; do + if [ "${arch}" == "armv7" ] && [ "${os}" != "Linux" ]; then + continue + fi if [ "${os}" == "Linux" ] && [ "${arch}" == "arm64" ]; then arch="aarch64" fi @@ -128,7 +141,10 @@ for os in Darwin Linux Windows; do done for os in Darwin Linux; do - for arch in x86_64 arm64; do + for arch in x86_64 arm64 armv7; do + if [ "${arch}" == "armv7" ] && [ "${os}" != "Linux" ]; then + continue + fi if [ "${os}" == "Linux" ] && [ "${arch}" == "arm64" ]; then arch="aarch64" fi