From e600be6f45d5f48abbcf16f6b2434c811c05f078 Mon Sep 17 00:00:00 2001 From: kzkzzzz Date: Wed, 8 Jun 2022 17:05:07 +0800 Subject: [PATCH] =?UTF-8?q?=E7=B2=BE=E7=AE=80makefile?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Makefile | 68 +------------------------------------------------------- 1 file changed, 1 insertion(+), 67 deletions(-) diff --git a/Makefile b/Makefile index 13c1598..fc0adaf 100644 --- a/Makefile +++ b/Makefile @@ -1,70 +1,4 @@ -GOPATH:=$(shell go env GOPATH) -VERSION=$(shell git describe --tags --always) -INTERNAL_PROTO_FILES=$(shell find internal -name *.proto) -API_PROTO_FILES=$(shell find api -name *.proto) - -.PHONY: init -# init env -init: - go install google.golang.org/protobuf/cmd/protoc-gen-go@latest - go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest - go install github.com/go-kratos/kratos/cmd/kratos/v2@latest - go install github.com/go-kratos/kratos/cmd/protoc-gen-go-http/v2@latest - go install github.com/google/gnostic/cmd/protoc-gen-openapi@latest - -.PHONY: config -# generate internal proto -config: - protoc --proto_path=./internal \ - --proto_path=./third_party \ - --go_out=paths=source_relative:./internal \ - $(INTERNAL_PROTO_FILES) - -.PHONY: api -# generate api proto -api: - protoc --proto_path=./api \ - --proto_path=./third_party \ - --go_out=paths=source_relative:./api \ - --go-http_out=paths=source_relative:./api \ - --go-grpc_out=paths=source_relative:./api \ - --openapi_out=fq_schema_naming=true,default_response=false:. \ - $(API_PROTO_FILES) - .PHONY: build # build build: - mkdir -p bin/ && go build -ldflags "-X main.Version=$(VERSION)" -o ./bin/ ./... - -.PHONY: generate -# generate -generate: - go mod tidy - go get github.com/google/wire/cmd/wire@latest - go generate ./... - -.PHONY: all -# generate all -all: - make api; - make config; - make generate; - -# show help -help: - @echo '' - @echo 'Usage:' - @echo ' make [target]' - @echo '' - @echo 'Targets:' - @awk '/^[a-zA-Z\-\_0-9]+:/ { \ - helpMessage = match(lastLine, /^# (.*)/); \ - if (helpMessage) { \ - helpCommand = substr($$1, 0, index($$1, ":")-1); \ - helpMessage = substr(lastLine, RSTART + 2, RLENGTH); \ - printf "\033[36m%-22s\033[0m %s\n", helpCommand,helpMessage; \ - } \ - } \ - { lastLine = $$0 }' $(MAKEFILE_LIST) - -.DEFAULT_GOAL := help + mkdir -p bin/ && go build -ldflags "-X main.Version=$(VERSION)" -o ./bin/ ./... \ No newline at end of file -- 2.22.0