You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: release-tools/build.make
+77-7
Original file line number
Diff line number
Diff line change
@@ -60,18 +60,25 @@ else
60
60
TESTARGS =
61
61
endif
62
62
63
-
ARCH := $(if$(GOARCH),$(GOARCH),$(shell go env GOARCH))
64
-
65
63
# Specific packages can be excluded from each of the tests below by setting the *_FILTER_CMD variables
66
64
# to something like "| grep -v 'github.com/kubernetes-csi/project/pkg/foobar'". See usage below.
67
65
66
+
# BUILD_PLATFORMS contains a set of <os> <arch> <suffix> triplets,
67
+
# separated by semicolon. An empty variable or empty entry (= just a
68
+
# semicolon) builds for the default platform of the current Go
69
+
# toolchain.
70
+
BUILD_PLATFORMS =
71
+
72
+
# This builds each command (= the sub-directories of ./cmd) for the target platform(s)
73
+
# defined by BUILD_PLATFORMS.
68
74
build-%: check-go-version-go
69
75
mkdir -p bin
70
-
CGO_ENABLED=0 GOOS=linux go build $(GOFLAGS_VENDOR) -a -ldflags '-X main.version=$(REV) -extldflags "-static"' -o ./bin/$* ./cmd/$*
71
-
if [ "$$ARCH"="amd64" ];then \
72
-
CGO_ENABLED=0 GOOS=windows go build $(GOFLAGS_VENDOR) -a -ldflags '-X main.version=$(REV) -extldflags "-static"' -o ./bin/$*.exe ./cmd/$*;\
73
-
CGO_ENABLED=0 GOOS=linux GOARCH=ppc64le go build $(GOFLAGS_VENDOR) -a -ldflags '-X main.version=$(REV) -extldflags "-static"' -o ./bin/$*-ppc64le ./cmd/$*;\
74
-
fi
76
+
echo'$(BUILD_PLATFORMS)'| tr ';''\n'|whileread -r os arch suffix;do \
77
+
if! (set -x; CGO_ENABLED=0 GOOS="$$os" GOARCH="$$arch" go build $(GOFLAGS_VENDOR) -a -ldflags '-X main.version=$(REV) -extldflags "-static"' -o "./bin/$*$$suffix" ./cmd/$*);then \
78
+
echo"Building $* for GOOS=$$os GOARCH=$$arch failed, see error(s) above.";\
79
+
exit 1;\
80
+
fi;\
81
+
done
75
82
76
83
container-%: build-%
77
84
docker build -t $*:latest -f $(shell if [ -e ./cmd/$*/Dockerfile ]; then echo ./cmd/$*/Dockerfile; else echo Dockerfile; fi) --label revision=$(REV).
@@ -98,6 +105,69 @@ build: $(CMDS:%=build-%)
98
105
container: $(CMDS:%=container-%)
99
106
push: $(CMDS:%=push-%)
100
107
108
+
# Additional parameters are needed when pushing to a local registry,
109
+
# see https://github.com/docker/buildx/issues/94.
110
+
# However, that then runs into https://github.com/docker/cli/issues/2396.
111
+
#
112
+
# What works for local testing is:
113
+
# make push-multiarch PULL_BASE_REF=master REGISTRY_NAME=<your account on dockerhub.io> BUILD_PLATFORMS="linux amd64; windows amd64 .exe; linux ppc64le -ppc64le; linux s390x -s390x"
114
+
DOCKER_BUILDX_CREATE_ARGS ?=
115
+
116
+
# This target builds a multiarch image for one command using Moby BuildKit builder toolkit.
117
+
# Docker Buildx is included in Docker 19.03.
118
+
#
119
+
# ./cmd/<command>/Dockerfile[.Windows] is used if found, otherwise Dockerfile[.Windows].
120
+
# BUILD_PLATFORMS determines which individual images are included in the multiarch image.
121
+
# PULL_BASE_REF must be set to 'master', 'release-x.y', or a tag name, and determines
Copy file name to clipboardExpand all lines: release-tools/prow.sh
+34-12
Original file line number
Diff line number
Diff line change
@@ -85,6 +85,8 @@ get_versioned_variable () {
85
85
echo"$value"
86
86
}
87
87
88
+
configvar CSI_PROW_BUILD_PLATFORMS "linux amd64; windows amd64 .exe; linux ppc64le -ppc64le; linux s390x -s390x""Go target platforms (= GOOS + GOARCH) and file suffix of the resulting binaries"
89
+
88
90
# If we have a vendor directory, then use it. We must be careful to only
89
91
# use this for "make" invocations inside the project's repo itself because
90
92
# setting it globally can break other go usages (like "go get <some command>"
run_with_go "${CSI_PROW_GO_VERSION_BUILD}" make all "GOFLAGS_VENDOR=${GOFLAGS_VENDOR}"|| die "'make all' failed"
1031
+
run_with_go "${CSI_PROW_GO_VERSION_BUILD}" make all "GOFLAGS_VENDOR=${GOFLAGS_VENDOR}""BUILD_PLATFORMS=${CSI_PROW_BUILD_PLATFORMS}"|| die "'make all' failed"
1030
1032
# We don't want test failures to prevent E2E testing below, because the failure
1031
1033
# might have been minor or unavoidable, for example when experimenting with
1032
1034
# changes in "release-tools" in a PR (that fails the "is release-tools unmodified"
0 commit comments