From 5de2115f4dbb207aae8b84839e7e842d8fe34671 Mon Sep 17 00:00:00 2001 From: Gary Edgar Date: Wed, 7 Apr 2021 18:33:39 -0700 Subject: [PATCH 1/3] Makefile: add xbuild target for cross-compiling client (vtexplain, vtctlclient) binaries Signed-off-by: Gary Edgar --- Makefile | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Makefile b/Makefile index c49dd08594c..302558080ab 100644 --- a/Makefile +++ b/Makefile @@ -75,6 +75,23 @@ endif # build vtorc with CGO, because it depends on sqlite CGO_ENABLED=1 go install $(EXTRA_BUILD_FLAGS) $(VT_GO_PARALLEL) -ldflags "$(shell tools/build_version_flags.sh)" ./go/cmd/vtorc/... +# xbuild can be used to cross-compile Vitess client binaries +# Outside of select client binaries (namely vtctlclient & vtexplain), cross-compiled Vitess Binaries are not recommended for production deployments +# Usage: GOOS=darwin GOARCH=amd64 make xbuild +xbuild: +ifndef NOBANNER + echo $$(date): Building source tree +endif + bash ./build.env + # In order to cross-compile, go install requires GOBIN to be unset + export GOBIN="" + # For the specified GOOS + GOARCH, build all the binaries by default with CGO disabled + CGO_ENABLED=0 GOOS=${GOOS} GOARCH=${GOARCH} go install $(EXTRA_BUILD_FLAGS) $(VT_GO_PARALLEL) -ldflags "$(shell tools/build_version_flags.sh)" ./go/... + # unset GOOS and embed local resources in the vttablet executable + (cd go/cmd/vttablet && unset GOOS && go run github.com/GeertJohan/go.rice/rice --verbose append --exec=$${HOME}/go/bin/${GOOS}_${GOARCH}/vttablet) + # Cross-compiling w/ cgo isn't trivial and we don't need vtorc, so we can skip building it + #CGO_ENABLED=1 GOOS=${GOOS} GOARCH=${GOARCH} go install $(EXTRA_BUILD_FLAGS) $(VT_GO_PARALLEL) -ldflags "$(shell tools/build_version_flags.sh)" ./go/cmd/vtorc/... + debug: ifndef NOBANNER echo $$(date): Building source tree From 32be42bf1401e51a8412b931a3413b8e71d10322 Mon Sep 17 00:00:00 2001 From: Gary Edgar Date: Thu, 8 Apr 2021 10:42:08 -0700 Subject: [PATCH 2/3] Makefile: remove unneeded comment Signed-off-by: Gary Edgar --- Makefile | 1 - 1 file changed, 1 deletion(-) diff --git a/Makefile b/Makefile index 302558080ab..0f75ba65854 100644 --- a/Makefile +++ b/Makefile @@ -90,7 +90,6 @@ endif # unset GOOS and embed local resources in the vttablet executable (cd go/cmd/vttablet && unset GOOS && go run github.com/GeertJohan/go.rice/rice --verbose append --exec=$${HOME}/go/bin/${GOOS}_${GOARCH}/vttablet) # Cross-compiling w/ cgo isn't trivial and we don't need vtorc, so we can skip building it - #CGO_ENABLED=1 GOOS=${GOOS} GOARCH=${GOARCH} go install $(EXTRA_BUILD_FLAGS) $(VT_GO_PARALLEL) -ldflags "$(shell tools/build_version_flags.sh)" ./go/cmd/vtorc/... debug: ifndef NOBANNER From 735b236be198d1f6b5169ffbc32db80329b37466 Mon Sep 17 00:00:00 2001 From: Gary Edgar Date: Mon, 12 Apr 2021 09:42:19 -0700 Subject: [PATCH 3/3] Makefile: address target name feedback Signed-off-by: Gary Edgar --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 0f75ba65854..ca1136b017b 100644 --- a/Makefile +++ b/Makefile @@ -78,7 +78,7 @@ endif # xbuild can be used to cross-compile Vitess client binaries # Outside of select client binaries (namely vtctlclient & vtexplain), cross-compiled Vitess Binaries are not recommended for production deployments # Usage: GOOS=darwin GOARCH=amd64 make xbuild -xbuild: +cross-build: ifndef NOBANNER echo $$(date): Building source tree endif