-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathMakefile
More file actions
64 lines (52 loc) · 2 KB
/
Makefile
File metadata and controls
64 lines (52 loc) · 2 KB
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
.PHONY: proto build test deps
SHELL=/usr/bin/env bash
export GOPRIVATE=github.com/anyproto
export PATH:=$(CURDIR)/deps:$(PATH)
export CGO_ENABLED:=1
BUILD_GOOS:=$(shell go env GOOS)
BUILD_GOARCH:=$(shell go env GOARCH)
ifeq ($(CGO_ENABLED), 0)
TAGS:=-tags nographviz
else
TAGS:=
endif
build:
@$(eval FLAGS := $$(shell PATH=$(PATH) govvv -flags -pkg github.com/anyproto/any-sync/app))
GOOS=$(BUILD_GOOS) GOARCH=$(BUILD_GOARCH) go build -v $(TAGS) -o bin/any-sync-node -ldflags "$(FLAGS) -X github.com/anyproto/any-sync/app.AppName=any-sync-node" github.com/anyproto/any-sync-node/cmd
test:
go test ./... --cover $(TAGS)
PROTOC=protoc
PROTOC_GEN_GO=deps/protoc-gen-go
PROTOC_GEN_DRPC=deps/protoc-gen-go-drpc
PROTOC_GEN_VTPROTO=deps/protoc-gen-go-vtproto
define generate_proto
@echo "Generating Protobuf for directory: $(1)"
$(PROTOC) \
--go_out=. --plugin protoc-gen-go="$(PROTOC_GEN_GO)" \
--go-vtproto_out=. --plugin protoc-gen-go-vtproto="$(PROTOC_GEN_VTPROTO)" \
--go-vtproto_opt=features=marshal+unmarshal+size \
--proto_path=$(1) $(wildcard $(1)/*.proto)
endef
define generate_drpc
@echo "Generating Protobuf for directory: $(1) $(which protoc-gen-go)"
$(PROTOC) \
--go_out=. --plugin protoc-gen-go=$$(which protoc-gen-go) \
--plugin protoc-gen-go-drpc=$(PROTOC_GEN_DRPC) \
--go_opt=$(1) \
--go-vtproto_out=:. --plugin protoc-gen-go-vtproto=$(PROTOC_GEN_VTPROTO) \
--go-vtproto_opt=features=marshal+unmarshal+size \
--go-drpc_out=protolib=github.com/planetscale/vtprotobuf/codec/drpc:. $(wildcard $(2)/*.proto)
endef
deps:
go mod download
go build -o deps storj.io/drpc/cmd/protoc-gen-go-drpc
go build -o deps google.golang.org/protobuf/cmd/protoc-gen-go
go build -o deps github.com/planetscale/vtprotobuf/cmd/protoc-gen-go-vtproto
go build -o deps github.com/ahmetb/govvv
go build -o deps go.uber.org/mock/mockgen
mocks:
echo 'Generating mocks...'
go generate ./...
proto:
$(call generate_drpc,,nodesync/nodesyncproto/protos)
$(call generate_drpc,,debug/nodedebugrpc/nodedebugrpcproto/protos)