Makefile 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. GOHOSTOS:=$(shell go env GOHOSTOS)
  2. GOPATH:=$(shell go env GOPATH)
  3. VERSION=$(shell git describe --tags --always)
  4. ifeq ($(GOHOSTOS), windows)
  5. #the `find.exe` is different from `find` in bash/shell.
  6. #to see https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/find.
  7. #changed to use git-bash.exe to run find cli or other cli friendly, caused of every developer has a Git.
  8. #Git_Bash= $(subst cmd\,bin\bash.exe,$(dir $(shell where git)))
  9. Git_Bash=$(subst \,/,$(subst cmd\,bin\bash.exe,$(dir $(shell where git))))
  10. API_PROTO_FILES=$(shell $(Git_Bash) -c "find . -not -path ./third_party/* -name *.proto")
  11. else
  12. API_PROTO_FILES=$(shell find . -not -path "./third_party/*" -name *.proto)
  13. endif
  14. .PHONY: init
  15. # init env
  16. init:
  17. go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
  18. go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
  19. go install github.com/go-kratos/kratos/cmd/kratos/v2@latest
  20. go install github.com/go-kratos/kratos/cmd/protoc-gen-go-http/v2@latest
  21. go install github.com/google/gnostic/cmd/protoc-gen-openapi@latest
  22. go install github.com/google/wire/cmd/wire@latest
  23. .PHONY: errors
  24. # generate internal proto
  25. errors:
  26. protoc --proto_path=./ \
  27. --proto_path=./third_party \
  28. --go_out=paths=source_relative:./ \
  29. --go-errors_out=paths=source_relative:./ \
  30. $(API_PROTO_FILES)
  31. .PHONY: api
  32. # generate api proto
  33. api:
  34. protoc --proto_path=./ \
  35. --proto_path=./third_party \
  36. --go_out=paths=source_relative:./ \
  37. --go-http_out=paths=source_relative:./ \
  38. --go-grpc_out=paths=source_relative:./ \
  39. --openapi_out=fq_schema_naming=true,default_response=false:. \
  40. $(API_PROTO_FILES)
  41. .PHONY: all
  42. # generate all
  43. all:
  44. make api;
  45. make errors;