Skip to content

Commit

Permalink
Merge pull request #7806 from planetscale/planetscale/gedgar-xbuild
Browse files Browse the repository at this point in the history
Makefile: add cross-build target for cross-compiling client binaries
  • Loading branch information
deepthi authored Apr 12, 2021
2 parents cdaa28a + 735b236 commit 85f598d
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,22 @@ 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
cross-build:
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

debug:
ifndef NOBANNER
echo $$(date): Building source tree
Expand Down

0 comments on commit 85f598d

Please sign in to comment.