-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
72 lines (49 loc) · 1.7 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
gomod := github.com/planetscale/vitess-types
PROTO_OUT := gen
PROTO_SRC := src
VITESS_PROTO_ROOT := $(PROTO_SRC)/vitess
VERSIONS := $(addprefix $(VITESS_PROTO_ROOT)/,$(shell jq -r '.versions | to_entries[].key' manifest.json))
BIN := bin
clean: clean-proto clean-bin
clean-proto:
rm -rf $(PROTO_OUT)
clean-bin:
rm -rf $(BIN)
$(BIN):
mkdir -p $(BIN)
$(PROTO_OUT):
mkdir -p $(PROTO_OUT)
TOOL_INSTALL := env GOBIN=$(PWD)/$(BIN) go install
$(BIN)/protoc-gen-go: go.mod | $(BIN)
$(TOOL_INSTALL) google.golang.org/protobuf/cmd/protoc-gen-go
$(BIN)/protoc-gen-go-vtproto: Makefile | $(BIN)
$(TOOL_INSTALL) github.com/planetscale/vtprotobuf/cmd/[email protected]
$(BIN)/protoc-gen-connect-go: go.mod | $(BIN)
$(TOOL_INSTALL) connectrpc.com/connect/cmd/protoc-gen-connect-go
$(BIN)/gofumpt: Makefile | $(BIN)
$(TOOL_INSTALL) mvdan.cc/[email protected]
$(BIN)/buf: Makefile | $(BIN)
$(TOOL_INSTALL) github.com/bufbuild/buf/cmd/[email protected]
$(BIN)/yq: Makefile | $(BIN)
$(TOOL_INSTALL) github.com/mikefarah/yq/[email protected]
PROTO_TOOLS := $(BIN)/protoc-gen-go $(BIN)/protoc-gen-connect-go $(BIN)/protoc-gen-go-vtproto $(BIN)/buf
tools: $(PROTO_TOOLS) $(BIN)/gofumpt $(BIN)/staticcheck $(BIN)/govulncheck $(BIN)/yq
proto: $(PROTO_TOOLS)
$(BIN)/buf generate -v
fd . -t f -e connect.go -X go run scripts/fix-service-names.go --
download:
go run scripts/download.go
$(MAKE) clean-proto proto
fmt: fmt-go fmt-proto
fmt-go: $(BIN)/gofumpt
$(BIN)/gofumpt -l -w .
fmt-yaml: $(BIN)/yq
fd . -t f -e yaml -e yml -x $(BIN)/yq -iP eval-all . {} \;
update:
go get -v -u ./...
go mod tidy
$(MAKE) clean proto
.PHONY: proto tools update \
clean clean-proto clean-bin \
fmt fmt-go fmt-yaml \
download $(VERSIONS)