Skip to content

Commit

Permalink
support GOBUILD_OPT pass to Makefile (matrixorigin#21221)
Browse files Browse the repository at this point in the history
support "make GOBUILD_OPT=-cover" to allow build with coverage test.

Approved by: @zhangxu19830126
  • Loading branch information
cpegeric authored Jan 14, 2025
1 parent d8e16e5 commit f18cb22
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ CGO_OPTS :=
GOLDFLAGS=-ldflags="-X '$(GO_MODULE)/pkg/version.GoVersion=$(GO_VERSION)' -X '$(GO_MODULE)/pkg/version.BranchName=$(BRANCH_NAME)' -X '$(GO_MODULE)/pkg/version.CommitID=$(LAST_COMMIT_ID)' -X '$(GO_MODULE)/pkg/version.BuildTime=$(BUILD_TIME)' -X '$(GO_MODULE)/pkg/version.Version=$(MO_VERSION)'"
TAGS :=

ifeq ($(GOBUILD_OPT),)
GOBUILD_OPT :=
endif

.PHONY: cgo
cgo:
@(cd cgo; ${MAKE} ${CGO_DEBUG_OPT})
Expand All @@ -110,7 +114,7 @@ cgo:
.PHONY: build
build: config
$(info [Build binary])
$(CGO_OPTS) go build $(TAGS) $(RACE_OPT) $(GOLDFLAGS) $(DEBUG_OPT) -o $(BIN_NAME) ./cmd/mo-service
$(CGO_OPTS) go build $(TAGS) $(RACE_OPT) $(GOLDFLAGS) $(DEBUG_OPT) $(GOBUILD_OPT) -o $(BIN_NAME) ./cmd/mo-service

.PHONY: musl-install
musl-install:
Expand All @@ -135,7 +139,7 @@ musl: override TAGS := -tags musl
musl: musl-install musl-cgo config
musl:
$(info [Build binary(musl)])
$(CGO_OPTS) go build $(TAGS) $(RACE_OPT) $(GOLDFLAGS) $(DEBUG_OPT) -o $(BIN_NAME) ./cmd/mo-service
$(CGO_OPTS) go build $(TAGS) $(RACE_OPT) $(GOLDFLAGS) $(DEBUG_OPT) $(GOBUILD_OPT) -o $(BIN_NAME) ./cmd/mo-service

# build mo-tool
.PHONY: mo-tool
Expand Down

0 comments on commit f18cb22

Please sign in to comment.