From 040d9142ff67254b53d345842dd6a3f91556cc2f Mon Sep 17 00:00:00 2001 From: Congqi Xia Date: Mon, 29 Jul 2024 18:55:50 +0800 Subject: [PATCH 1/2] enhance: Refine protobuf dependency installation in Makefile Related to #34394 Signed-off-by: Congqi Xia --- Makefile | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 27b4bf6337ade..e34b4e91084c5 100644 --- a/Makefile +++ b/Makefile @@ -60,6 +60,14 @@ INSTALL_GOFUMPT := $(findstring $(GOFUMPT_VERSION),$(GOFUMPT_OUTPUT)) GOTESTSUM_VERSION := 1.11.0 GOTESTSUM_OUTPUT := $(shell $(INSTALL_PATH)/gotestsum --version 2>/dev/null) INSTALL_GOTESTSUM := $(findstring $(GOTESTSUM_VERSION),$(GOTESTSUM_OUTPUT)) +# protoc-gen-go +PROTOC_GEN_GO_VERSION := 1.33.0 +PROTOC_GEN_GO_OUTPUT := $(shell print | $(INSTALL_PATH)/protoc-gen-go --version 2>/dev/null) +INSTALL_PROTOC_GEN_GO := $(findstring $(PROTOC_GEN_GO_VERSION),$(PROTOC_GEN_GO_OUTPUT)) +# protoc-gen-go-grpc +PROTOC_GEN_GO_GRPC_VERSION := 1.3.0 +PROTOC_GEN_GO_GRPC_OUTPUT := $(shell print | $(INSTALL_PATH)/protoc-gen-go-grpc --version 2>/dev/null) +INSTALL_PROTOC_GEN_GO_GRPC := $(findstring $(PROTOC_GEN_GO_GRPC_VERSION),$(PROTOC_GEN_GO_GRPC_OUTPUT)) index_engine = knowhere @@ -69,6 +77,9 @@ ifeq (${ENABLE_AZURE}, false) AZURE_OPTION := -Z endif +test: + @echo $(INSTALL_PROTOC_GEN_GO) $(PROTOC_GEN_GO_GRPC_OUTPUT) + milvus: build-cpp print-build-info @echo "Building Milvus ..." @source $(PWD)/scripts/setenv.sh && \ @@ -105,6 +116,19 @@ getdeps: echo "gotestsum v$(GOTESTSUM_VERSION) already installed";\ fi +get-proto-deps: + @mkdir -p $(INSTALL_PATH) # make sure directory exists + @if [ -z "$(INSTALL_PROTOC_GEN_GO)" ]; then \ + echo "install protoc-gen-go $(PROTOC_GEN_GO_VERSION) to $(INSTALL_PATH)" && GOBIN=$(INSTALL_PATH) go install google.golang.org/protobuf/cmd/protoc-gen-go@v$(PROTOC_GEN_GO_VERSION); \ + else \ + echo "protoc-gen-go@v$(PROTOC_GEN_GO_VERSION) already installed";\ + fi + @if [ -z "$(INSTALL_PROTOC_GEN_GO_GRPC)" ]; then \ + echo "install protoc-gen-go-grpc $(PROTOC_GEN_GO_GRPC_VERSION) to $(INSTALL_PATH)" && GOBIN=$(INSTALL_PATH) go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v$(PROTOC_GEN_GO_GRPC_VERSION); \ + else \ + echo "protoc-gen-go-grpc@v$(PROTOC_GEN_GO_GRPC_VERSION) already installed";\ + fi + tools/bin/revive: tools/check/go.mod cd tools/check; \ $(GO) build -pgo=$(PGO_PATH)/default.pgo -o ../bin/revive github.com/mgechev/revive @@ -223,18 +247,12 @@ build-3rdparty: @echo "Build 3rdparty ..." @(env bash $(PWD)/scripts/3rdparty_build.sh -o ${use_opendal}) -generated-proto-without-cpp: download-milvus-proto +generated-proto-without-cpp: download-milvus-proto get-proto-deps @echo "Generate proto ..." - @mkdir -p ${INSTALL_PATH} - @which protoc-gen-go 1>/dev/null || (echo "Installing protoc-gen-go" && GOBIN=${INSTALL_PATH} go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.33.0) - @which protoc-gen-go-grpc 1>/dev/null || (echo "Installing protoc-gen-go-grpc" && GOBIN=${INSTALL_PATH} go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.3.0) @(env bash $(PWD)/scripts/generate_proto.sh ${INSTALL_PATH}) -generated-proto: download-milvus-proto build-3rdparty +generated-proto: download-milvus-proto build-3rdparty get-proto-deps @echo "Generate proto ..." - @mkdir -p ${INSTALL_PATH} - @which protoc-gen-go 1>/dev/null || (echo "Installing protoc-gen-go" && GOBIN=${INSTALL_PATH} go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.33.0) - @which protoc-gen-go-grpc 1>/dev/null || (echo "Installing protoc-gen-go-grpc" && GOBIN=${INSTALL_PATH} go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.3.0) @(env bash $(PWD)/scripts/generate_proto.sh ${INSTALL_PATH}) build-cpp: generated-proto From a92063780f0a23efb3ecbb095265d958b89c1585 Mon Sep 17 00:00:00 2001 From: Congqi Xia Date: Mon, 29 Jul 2024 19:43:04 +0800 Subject: [PATCH 2/2] Remove test item Signed-off-by: Congqi Xia --- Makefile | 3 --- 1 file changed, 3 deletions(-) diff --git a/Makefile b/Makefile index e34b4e91084c5..8a738964ea41d 100644 --- a/Makefile +++ b/Makefile @@ -77,9 +77,6 @@ ifeq (${ENABLE_AZURE}, false) AZURE_OPTION := -Z endif -test: - @echo $(INSTALL_PROTOC_GEN_GO) $(PROTOC_GEN_GO_GRPC_OUTPUT) - milvus: build-cpp print-build-info @echo "Building Milvus ..." @source $(PWD)/scripts/setenv.sh && \