Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bake/bin-image-cross: Add darwin #4996

Merged
merged 3 commits into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ ARG PACKAGER_NAME
COPY --link --from=goversioninfo /out/goversioninfo /usr/bin/goversioninfo
RUN --mount=type=bind,target=.,ro \
--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 \
# override the default behavior of go with xx-go
xx-go --wrap && \
Expand All @@ -89,7 +88,6 @@ ARG GO_STRIP
ARG CGO_ENABLED
ARG VERSION
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 && \
TARGET=/out ./scripts/build/plugins e2e/cli-plugins/plugins/*

Expand Down
2 changes: 2 additions & 0 deletions docker-bake.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,8 @@ target "bin-image-cross" {
inherits = ["bin-image"]
output = ["type=image"]
platforms = [
"darwin/amd64",
"darwin/arm64",
"linux/amd64",
"linux/arm/v6",
"linux/arm/v7",
Expand Down
10 changes: 10 additions & 0 deletions scripts/build/.variables
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,16 @@ if [ "${GOOS}" = "windows" ]; then
fi
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
case "$(go env GOOS)" in
linux)
Expand Down
Loading