Skip to content

Commit

Permalink
build virtctl also for arm64
Browse files Browse the repository at this point in the history
When we build on linux on amd64 we are already
building virtctl also for darwin and windows
OSs but still only for amd64.
But client architecture could differ the cluster ones.

kubectl for instance is shipped for linux, darwin
and windows in both amd64 and arm64 architectures.
Check as a reference:
- https://dl.k8s.io/release/v1.27.2/bin/linux/amd64/kubectl
- https://dl.k8s.io/release/v1.27.0/bin/linux/arm64/kubectl
- https://dl.k8s.io/release/v1.27.2/bin/darwin/amd64/kubectl
- https://dl.k8s.io/release/v1.27.2/bin/darwin/arm64/kubectl
- https://dl.k8s.io/release/v1.27.2/bin/windows/amd64/kubectl.exe
- https://dl.k8s.io/release/v1.27.2/bin/windows/arm64/kubectl.exe

Let's start taking the same approach for virtctl.

Signed-off-by: Simone Tiraboschi <[email protected]>
  • Loading branch information
tiraboschi committed Jun 1, 2023
1 parent e291f5f commit 52b0959
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions hack/build-go.sh
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,14 @@ for arg in $args; do
kubevirt::version::get_version_vars
echo "$KUBEVIRT_GIT_VERSION" >${CMD_OUT_DIR}/${BIN_NAME}/.version

# build virtctl also for darwin and windows on amd64
# build virtctl also for darwin and windows and for arm64 when on amd64 on linux
if [ "${BIN_NAME}" = "virtctl" -a "${ARCH}" = "amd64" -a -z "${LINUX_ONLY}" ]; then
GOOS=darwin GOARCH=amd64 go_build -tags "${KUBEVIRT_GO_BUILD_TAGS}" -o ${CMD_OUT_DIR}/${BIN_NAME}/${ARCH_BASENAME}-darwin-amd64 -ldflags "$(kubevirt::version::ldflags)" $(pkg_dir darwin amd64)
GOOS=windows GOARCH=amd64 go_build -tags "${KUBEVIRT_GO_BUILD_TAGS}" -o ${CMD_OUT_DIR}/${BIN_NAME}/${ARCH_BASENAME}-windows-amd64.exe -ldflags "$(kubevirt::version::ldflags)" $(pkg_dir windows amd64)
# Create symlinks to the latest binary of each architecture
GOOS=linux GOARCH=arm64 go_build -tags "${KUBEVIRT_GO_BUILD_TAGS}" -o ${CMD_OUT_DIR}/${BIN_NAME}/${ARCH_BASENAME}-linux-arm64 -ldflags "$(kubevirt::version::ldflags)" $(pkg_dir linux arm64)
GOOS=windows GOARCH=arm64 go_build -tags "${KUBEVIRT_GO_BUILD_TAGS}" -o ${CMD_OUT_DIR}/${BIN_NAME}/${ARCH_BASENAME}-windows-arm64.exe -ldflags "$(kubevirt::version::ldflags)" $(pkg_dir windows arm64)
GOOS=darwin GOARCH=arm64 go_build -tags "${KUBEVIRT_GO_BUILD_TAGS}" -o ${CMD_OUT_DIR}/${BIN_NAME}/${ARCH_BASENAME}-darwin-arm64 -ldflags "$(kubevirt::version::ldflags)" $(pkg_dir darwin arm64)
# Create symlinks to the latest binary of amd64 architecture
(cd ${CMD_OUT_DIR}/${BIN_NAME} && ln -sf ${ARCH_BASENAME}-darwin-amd64 ${BIN_NAME}-darwin)
(cd ${CMD_OUT_DIR}/${BIN_NAME} && ln -sf ${ARCH_BASENAME}-windows-amd64.exe ${BIN_NAME}-windows.exe)
fi
Expand Down

0 comments on commit 52b0959

Please sign in to comment.