Skip to content

Commit

Permalink
Merge pull request kubevirt#5799 from vasiliy-ul/fix-native-go-build
Browse files Browse the repository at this point in the history
Fix native go build
  • Loading branch information
kubevirt-bot authored Jun 22, 2021
2 parents 371958b + fc120d8 commit a10478c
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ all:
hack/bazel-fmt.sh && hack/bazel-build.sh"

go-all:
hack/dockerized "KUBEVIRT_VERSION=${KUBEVIRT_VERSION} ./hack/build-go.sh install ${WHAT} && ./hack/build-copy-artifacts.sh ${WHAT} && DOCKER_PREFIX=${DOCKER_PREFIX} DOCKER_TAG=${DOCKER_TAG} IMAGE_PULL_POLICY=${IMAGE_PULL_POLICY} VERBOSITY=${VERBOSITY} ./hack/build-manifests.sh"
hack/dockerized "KUBEVIRT_VERSION=${KUBEVIRT_VERSION} ./hack/build-go.sh install ${WHAT} && ./hack/build-copy-artifacts.sh ${WHAT} && DOCKER_PREFIX=${DOCKER_PREFIX} DOCKER_TAG=${DOCKER_TAG} IMAGE_PULL_POLICY=${IMAGE_PULL_POLICY} VERBOSITY=${VERBOSITY} GO_BUILD=true ./hack/build-manifests.sh"

bazel-generate:
SYNC_VENDOR=true hack/dockerized "./hack/bazel-generate.sh"
Expand Down
8 changes: 4 additions & 4 deletions hack/build-go.sh
Original file line number Diff line number Diff line change
Expand Up @@ -116,17 +116,17 @@ for arg in $args; do
LINUX_NAME=${ARCH_BASENAME}-linux-${ARCH}

echo "building dynamic binary $BIN_NAME"
GOOS=linux GOARCH=${ARCH} go_build -tags selinux -i -o ${CMD_OUT_DIR}/${BIN_NAME}/${LINUX_NAME} -ldflags "$(kubevirt::version::ldflags)" $(pkg_dir linux ${ARCH})
GOOS=linux GOARCH=${ARCH} go_build -tags selinux -o ${CMD_OUT_DIR}/${BIN_NAME}/${LINUX_NAME} -ldflags "$(kubevirt::version::ldflags)" $(pkg_dir linux ${ARCH})

(cd ${CMD_OUT_DIR}/${BIN_NAME} && ln -sf ${LINUX_NAME} ${BIN_NAME})

kubevirt::version::get_version_vars
echo "$KUBEVIRT_GIT_VERSION" >${CMD_OUT_DIR}/${BIN_NAME}/.version

# build virtctl also for darwin and windows on amd64
if [ "${BIN_NAME}" = "virtctl" -a "${ARCH}" = "amd64" ]; then
GOOS=darwin GOARCH=amd64 go_build -i -o ${CMD_OUT_DIR}/${BIN_NAME}/${ARCH_BASENAME}-darwin-amd64 -ldflags "$(kubevirt::version::ldflags)" $(pkg_dir darwin amd64)
GOOS=windows GOARCH=amd64 go_build -i -o ${CMD_OUT_DIR}/${BIN_NAME}/${ARCH_BASENAME}-windows-amd64.exe -ldflags "$(kubevirt::version::ldflags)" $(pkg_dir windows amd64)
if [ "${BIN_NAME}" = "virtctl" -a "${ARCH}" = "amd64" -a -z "${LINUX_ONLY}" ]; then
GOOS=darwin GOARCH=amd64 go_build -o ${CMD_OUT_DIR}/${BIN_NAME}/${ARCH_BASENAME}-darwin-amd64 -ldflags "$(kubevirt::version::ldflags)" $(pkg_dir darwin amd64)
GOOS=windows GOARCH=amd64 go_build -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
(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)
Expand Down
10 changes: 7 additions & 3 deletions hack/build-manifests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,13 @@ rm -rf "${TESTS_OUT_DIR}/tools"
mkdir -p "${TESTS_OUT_DIR}/tools"
templator=${TESTS_OUT_DIR}/tools/manifest-templator

bazel run \
--config=${HOST_ARCHITECTURE} \
//:build-manifest-templator -- ${templator}
if [ -z "${GO_BUILD}" ]; then
bazel run \
--config=${HOST_ARCHITECTURE} \
//:build-manifest-templator -- ${templator}
else
(cd ${KUBEVIRT_DIR}/tools/manifest-templator/ && go_build && cp manifest-templator ${templator})
fi

# first process file includes only
args=$(cd ${KUBEVIRT_DIR}/manifests && find . -type f -name "*.yaml.in" -not -path "./generated/*")
Expand Down
2 changes: 1 addition & 1 deletion hack/config-default.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
binaries="cmd/virt-operator cmd/virt-controller cmd/virt-launcher cmd/virt-handler cmd/virtctl cmd/fake-qemu-process cmd/virt-api cmd/subresource-access-test cmd/example-hook-sidecar cmd/example-cloudinit-hook-sidecar"
binaries="cmd/virt-operator cmd/virt-controller cmd/virt-launcher cmd/virt-handler cmd/virtctl cmd/fake-qemu-process cmd/virt-api cmd/subresource-access-test cmd/example-hook-sidecar cmd/example-cloudinit-hook-sidecar cmd/virt-chroot"
docker_images="cmd/virt-operator cmd/virt-controller cmd/virt-launcher cmd/virt-handler cmd/virt-api images/disks-images-provider images/vm-killer images/nfs-server cmd/subresource-access-test images/winrmcli cmd/example-hook-sidecar cmd/example-cloudinit-hook-sidecar images/cdi-http-import-server tests/conformance"
docker_tag=${DOCKER_TAG:-latest}
docker_tag_alt=${DOCKER_TAG_ALT}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func NewHandlerDaemonSet(namespace string, repository string, imagePrefix string
Image: fmt.Sprintf("%s/%s%s%s", repository, imagePrefix, "virt-launcher", launcherVersion),
Name: "virt-launcher",
Args: []string{
"/bin/node-labeller.sh",
"node-labeller.sh",
},
SecurityContext: &corev1.SecurityContext{
Privileged: boolPtr(true),
Expand Down

0 comments on commit a10478c

Please sign in to comment.