diff --git a/Makefile b/Makefile index d2bbdd11bb..3890dce48f 100644 --- a/Makefile +++ b/Makefile @@ -159,23 +159,29 @@ else CGO_ENABLED=1 $(GOBUILD) -gcflags="all=-N -l" $(RACE_FLAG) -ldflags '$(LDFLAGS) $(CHECK_FLAG)' -o '$(TARGET)' ./tidb-server endif +init-submodule: + git submodule init && git submodule update --force + enterprise-prepare: - git submodule init && git submodule update && cd extension/enterprise/generate && $(GO) generate -run genfile main.go + cd extension/enterprise/generate && $(GO) generate -run genfile main.go enterprise-clear: cd extension/enterprise/generate && $(GO) generate -run clear main.go -enterprise-docker: enterprise-prepare +enterprise-docker: init-submodule enterprise-prepare docker build -t "$(DOCKERPREFIX)tidb:latest" --build-arg 'GOPROXY=$(shell go env GOPROXY),' -f Dockerfile.enterprise . enterprise-server-build: ifeq ($(TARGET), "") - CGO_ENABLED=1 $(GOBUILD) -tags enterprise $(RACE_FLAG) -ldflags '$(LDFLAGS) $(CHECK_FLAG)' -o bin/tidb-server tidb-server/main.go + CGO_ENABLED=1 $(GOBUILD) -tags enterprise $(RACE_FLAG) -ldflags '$(LDFLAGS) $(CHECK_FLAG) $(EXTENSION_FLAG)' -o bin/tidb-server tidb-server/main.go else - CGO_ENABLED=1 $(GOBUILD) -tags enterprise $(RACE_FLAG) -ldflags '$(LDFLAGS) $(CHECK_FLAG)' -o '$(TARGET)' tidb-server/main.go + CGO_ENABLED=1 $(GOBUILD) -tags enterprise $(RACE_FLAG) -ldflags '$(LDFLAGS) $(CHECK_FLAG) $(EXTENSION_FLAG)' -o '$(TARGET)' tidb-server/main.go endif -enterprise-server: enterprise-prepare enterprise-server-build +enterprise-server: + @make init-submodule + @make enterprise-prepare + @make enterprise-server-build server_check: ifeq ($(TARGET), "") diff --git a/Makefile.common b/Makefile.common index f2ba132767..66933c93fc 100644 --- a/Makefile.common +++ b/Makefile.common @@ -66,6 +66,11 @@ LDFLAGS += -X "github.com/pingcap/tidb/util/versioninfo.TiDBGitHash=$(shell git LDFLAGS += -X "github.com/pingcap/tidb/util/versioninfo.TiDBGitBranch=$(shell git rev-parse --abbrev-ref HEAD)" LDFLAGS += -X "github.com/pingcap/tidb/util/versioninfo.TiDBEdition=$(TIDB_EDITION)" +EXTENSION_FLAG = +ifeq ($(shell if [ -a extension/enterprise/.git ]; then echo "true"; fi),true) + EXTENSION_FLAG += -X "github.com/pingcap/tidb/util/versioninfo.TiDBEnterpriseExtensionGitHash=$(shell cd extension/enterprise && git rev-parse HEAD)" +endif + TEST_LDFLAGS = -X "github.com/pingcap/tidb/config.checkBeforeDropLDFlag=1" COVERAGE_SERVER_LDFLAGS = -X "github.com/pingcap/tidb/tidb-server.isCoverageServer=1" diff --git a/build/print-workspace-status.sh b/build/print-workspace-status.sh index dd2bd49081..f1909b8697 100755 --- a/build/print-workspace-status.sh +++ b/build/print-workspace-status.sh @@ -27,6 +27,10 @@ TiDB_BUILD_UTCTIME=$(date -u '+%Y-%m-%d %H:%M:%S') TIDB_GIT_HASH=$(git rev-parse HEAD) TIDB_GIT_BRANCH=$(git rev-parse --abbrev-ref HEAD) TIDB_EDITION=${TIDB_EDITION:-Community} +TIDB_ENTERPRISE_EXTENSION_GIT_HASH="" +if [ -a "extension/enterprise/.git" ]; then + TIDB_ENTERPRISE_EXTENSION_GIT_HASH=$(cd extension/enterprise && git rev-parse HEAD) +fi cat <