summaryrefslogtreecommitdiff
path: root/hack/lib/golang.sh
diff options
context:
space:
mode:
authorwujunyi <wu65830600@163.com>2023-09-26 01:57:38 +0800
committerwujunyi <wu65830600@163.com>2023-10-27 01:17:34 +0800
commit0a21d2bba6ac8f8d8172f5ac8b36a2d63b456334 (patch)
treeb213f679e38e36582ace55ff377c5e925b308b43 /hack/lib/golang.sh
parentMerge pull request #5114 from Shelley-BaoYue/master (diff)
downloadkubeedge-0a21d2bba6ac8f8d8172f5ac8b36a2d63b456334.tar.gz
feat: update to support release windows/amd64
Signed-off-by: wujunyi <wu65830600@163.com>
Diffstat (limited to 'hack/lib/golang.sh')
-rwxr-xr-xhack/lib/golang.sh29
1 files changed, 21 insertions, 8 deletions
diff --git a/hack/lib/golang.sh b/hack/lib/golang.sh
index aa93125d1..11edbe08f 100755
--- a/hack/lib/golang.sh
+++ b/hack/lib/golang.sh
@@ -261,11 +261,17 @@ kubeedge::golang::cross_build_place_binaries() {
local -a targets=()
local goarm=${goarm:-${KUBEEDGE_ALL_CROSS_GOARMS[0]}}
+ local goos="linux"
+ local goarch="amd64"
for arg in "$@"; do
if [[ "${arg}" == GOARM* ]]; then
# Assume arguments starting with a dash are flags to pass to go.
goarm="${arg##*GOARM}"
+ elif [[ "${arg}" == GOOS* ]]; then
+ goos="${arg##*GOOS}"
+ elif [[ "${arg}" == GOARCH* ]]; then
+ goarch="${arg##*GOARCH}"
else
targets+=("$(kubeedge::golang::get_target_by_binary $arg)")
fi
@@ -288,16 +294,23 @@ kubeedge::golang::cross_build_place_binaries() {
mkdir -p ${KUBEEDGE_OUTPUT_BINPATH}
for bin in ${binaries[@]}; do
- echo "cross building $bin GOARM${goarm}"
local name="${bin##*/}"
- if [ "${goarm}" == "8" ]; then
- set -x
- GOARM="" # need to clear the value since golang compiler doesn't allow this env when building the binary for ARMv8.
- GOARCH=arm64 GOOS="linux" CGO_ENABLED=1 CC=aarch64-linux-gnu-gcc go build -o ${KUBEEDGE_OUTPUT_BINPATH}/${name} -ldflags "$ldflags" $bin
- set +x
- elif [ "${goarm}" == "7" ]; then
+ if [ "${goos}" == "linux" ] ; then
+ echo "cross building $bin GOARM${goarm} ${goos} ${goarch}"
+ if [ "${goarm}" == "8" ]; then
+ set -x
+ GOARM="" # need to clear the value since golang compiler doesn't allow this env when building the binary for ARMv8.
+ GOARCH=arm64 GOOS=${goos} CGO_ENABLED=1 CC=aarch64-linux-gnu-gcc go build -o ${KUBEEDGE_OUTPUT_BINPATH}/${name} -ldflags "$ldflags" $bin
+ set +x
+ elif [ "${goarm}" == "7" ]; then
+ set -x
+ GOARCH=arm GOOS=${goos} GOARM=${goarm} CGO_ENABLED=1 CC=arm-linux-gnueabihf-gcc go build -o ${KUBEEDGE_OUTPUT_BINPATH}/${name} -ldflags "$ldflags" $bin
+ set +x
+ fi
+ elif [ "${goos}" == "windows" ]; then
+ echo "cross building $bin ${goos} ${goarch}"
set -x
- GOARCH=arm GOOS="linux" GOARM=${goarm} CGO_ENABLED=1 CC=arm-linux-gnueabihf-gcc go build -o ${KUBEEDGE_OUTPUT_BINPATH}/${name} -ldflags "$ldflags" $bin
+ GOARCH=${goarch} GOOS=${goos} CGO_ENABLED=1 CC=x86_64-w64-mingw32-gcc go build -o ${KUBEEDGE_OUTPUT_BINPATH}/${name} -ldflags "$ldflags" $bin
set +x
fi
done