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

build: Allow passing in custom -ldflags #13748

Merged
merged 1 commit into from
Aug 8, 2023
Merged
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
12 changes: 8 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ ifdef VT_EXTRA_BUILD_FLAGS
export EXTRA_BUILD_FLAGS := $(VT_EXTRA_BUILD_FLAGS)
endif

ifdef VT_EXTRA_BUILD_LDFLAGS
export EXTRA_BUILD_LDFLAGS := $(VT_EXTRA_BUILD_LDFLAGS)
endif

# This should be the root of the vitess Git directory.
ifndef VTROOT
export VTROOT=${PWD}
Expand All @@ -76,7 +80,7 @@ ifndef NOBANNER
endif
bash ./build.env
go build -trimpath $(EXTRA_BUILD_FLAGS) $(VT_GO_PARALLEL) \
-ldflags "$(shell tools/build_version_flags.sh)" \
-ldflags "$(EXTRA_BUILD_LDFLAGS) $(shell tools/build_version_flags.sh)" \
-o ${VTROOTBIN} ./go/...

# build the vitess binaries statically
Expand All @@ -89,7 +93,7 @@ endif
# Binaries will be placed in ${VTROOTBIN}.
CGO_ENABLED=0 go build \
-trimpath $(EXTRA_BUILD_FLAGS) $(VT_GO_PARALLEL) \
-ldflags "$(shell tools/build_version_flags.sh)" \
-ldflags "$(EXTRA_BUILD_LDFLAGS) $(shell tools/build_version_flags.sh)" \
-o ${VTROOTBIN} ./go/...
ifndef NOVTADMINBUILD
echo "Building VTAdmin Web, disable VTAdmin build by setting 'NOVTADMINBUILD'"
Expand All @@ -111,7 +115,7 @@ endif
mkdir -p ${VTROOTBIN}/${GOOS}_${GOARCH}
CGO_ENABLED=0 GOOS=${GOOS} GOARCH=${GOARCH} go build \
-trimpath $(EXTRA_BUILD_FLAGS) $(VT_GO_PARALLEL) \
-ldflags "$(shell tools/build_version_flags.sh)" \
-ldflags "$(EXTRA_BUILD_LDFLAGS) $(shell tools/build_version_flags.sh)" \
-o ${VTROOTBIN}/${GOOS}_${GOARCH} ./go/...

@if [ ! -x "${VTROOTBIN}/${GOOS}_${GOARCH}/vttablet" ]; then \
Expand All @@ -125,7 +129,7 @@ endif
bash ./build.env
go build -trimpath \
$(EXTRA_BUILD_FLAGS) $(VT_GO_PARALLEL) \
-ldflags "$(shell tools/build_version_flags.sh)" \
-ldflags "$(EXTRA_BUILD_LDFLAGS) $(shell tools/build_version_flags.sh)" \
-gcflags -'N -l' \
-o ${VTROOTBIN} ./go/...

Expand Down
Loading