Skip to content

Commit

Permalink
Add build for armv7 buf binaries (#3450)
Browse files Browse the repository at this point in the history
  • Loading branch information
nimish-ks authored Nov 7, 2024
1 parent fdc034f commit b4916b4
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions make/buf/scripts/release.bash
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ goarch() {
x86_64) echo amd64 ;;
arm64) echo arm64 ;;
aarch64) echo arm64 ;;
armv7) echo arm ;;
*) return 1 ;;
esac
}
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit b4916b4

Please sign in to comment.