Merge pull request #4996 from vvoland/cli-bin-darwin

bake/bin-image-cross: Add darwin
This commit is contained in:
Bjorn Neergaard 2024-05-21 06:25:30 -06:00 committed by GitHub
commit 997cfa699b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 12 additions and 2 deletions

View File

@ -63,7 +63,6 @@ ARG PACKAGER_NAME
COPY --link --from=goversioninfo /out/goversioninfo /usr/bin/goversioninfo COPY --link --from=goversioninfo /out/goversioninfo /usr/bin/goversioninfo
RUN --mount=type=bind,target=.,ro \ RUN --mount=type=bind,target=.,ro \
--mount=type=cache,target=/root/.cache \ --mount=type=cache,target=/root/.cache \
--mount=from=dockercore/golang-cross:xx-sdk-extras,target=/xx-sdk,src=/xx-sdk \
--mount=type=tmpfs,target=cli/winresources \ --mount=type=tmpfs,target=cli/winresources \
# override the default behavior of go with xx-go # override the default behavior of go with xx-go
xx-go --wrap && \ xx-go --wrap && \
@ -89,7 +88,6 @@ ARG GO_STRIP
ARG CGO_ENABLED ARG CGO_ENABLED
ARG VERSION ARG VERSION
RUN --mount=ro --mount=type=cache,target=/root/.cache \ RUN --mount=ro --mount=type=cache,target=/root/.cache \
--mount=from=dockercore/golang-cross:xx-sdk-extras,target=/xx-sdk,src=/xx-sdk \
xx-go --wrap && \ xx-go --wrap && \
TARGET=/out ./scripts/build/plugins e2e/cli-plugins/plugins/* TARGET=/out ./scripts/build/plugins e2e/cli-plugins/plugins/*

View File

@ -180,6 +180,8 @@ target "bin-image-cross" {
inherits = ["bin-image"] inherits = ["bin-image"]
output = ["type=image"] output = ["type=image"]
platforms = [ platforms = [
"darwin/amd64",
"darwin/arm64",
"linux/amd64", "linux/amd64",
"linux/arm/v6", "linux/arm/v6",
"linux/arm/v7", "linux/arm/v7",

View File

@ -44,6 +44,16 @@ if [ "${GOOS}" = "windows" ]; then
fi fi
export TARGET export TARGET
# No CGO when cross building to darwin
if [ "$(go env GOOS)" = "darwin" ] && [ "$(uname)" != "Darwin" ]; then
if [ -z "$CGO_ENABLED" ]; then
CGO_ENABLED=0
elif [ "$CGO_ENABLED" = "1" ]; then
echo "CGO_ENABLED=1 not supported when cross-compiling for Darwin"
exit 1
fi
fi
if [ -z "$CGO_ENABLED" ]; then if [ -z "$CGO_ENABLED" ]; then
case "$(go env GOOS)" in case "$(go env GOOS)" in
linux) linux)