include mk/* GOBIN ?= $(shell go env GOPATH)/bin PROTOC_VERSION ?= 25.6 PROTOC_ARCH = linux-x86_64 PROTOC = ./bin/protoc/bin/protoc UNAME = "$(shell uname)/$(shell uname -m)" ifeq ($(UNAME), "Darwin/arm64") PROTOC_ARCH = osx-aarch_64 endif ifeq ($(UNAME), "Darwin/x86_64") PROTOC_ARCH = osx-x86_64 endif PROTOC_URL ?= "https://github.com/protocolbuffers/protobuf/releases/download/v$(PROTOC_VERSION)/protoc-$(PROTOC_VERSION)-$(PROTOC_ARCH).zip" # Prepare binaries to generate protobuf files .PHONY: protoc-bin protoc-bin: ifeq (,$(wildcard ./bin/protoc)) curl --create-dirs -o ./bin/protoc.zip -L'#' $(PROTOC_URL) unzip ./bin/protoc.zip -d ./bin/protoc rm -r ./bin/protoc.zip ./bin/protoc/include ./bin/protoc/readme.txt endif # Generate protobuf file .PHONY: protoc protoc: protoc-bin @go list -f '{{.Path}}/...@{{.Version}}' -m google.golang.org/protobuf | xargs echo go install -v @for f in `find . -type f -name '*.proto'`; do \ echo "> Processing $$f "; \ $(PROTOC) --experimental_editions --plugin=protoc-gen-go=$(GOBIN)/protoc-gen-go --go_out=. --go_opt=paths=source_relative $$f \ --plugin=protoc-gen-go-grpc=$(GOBIN)/protoc-gen-go-grpc --go-grpc_out=. --go-grpc_opt=require_unimplemented_servers=false,paths=source_relative $$f; \ done # Run Unit Test with go test .PHONY: test test: GOFLAGS ?= "-count=1" test: @echo "> Running go test" @GOFLAGS="$(GOFLAGS)" go test ./... # Clean all installed files .PHONY: clean clean: rm -rf ./bin/*