-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
52 lines (39 loc) · 1.16 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
.SUFFIXES:
SOURCE = $(shell find pkg cmd -name '*.go')
RPC = $(shell find rpc -name '*.proto')
GO_TOOLS = $(shell grep _ tools.go | cut -d\" -f 2)
GO_TOOLS_DIR = _tools/bin/
GO_TOOLS_BIN = $(addprefix $(GO_TOOLS_DIR), $(notdir $(GO_TOOLS)))
export PATH:=${PWD}/${GO_TOOLS_DIR}:${PATH}
build: bin/api
@: # shhh
.PHONY: build
dev:
CompileDaemon \
-exclude-dir web \
-build make \
-command bin/api
.PHONY: dev
doc: doc/index.html
@: # shhh
.PHONY: doc
test:
@go test ./...
.PHONY: test
generate: doc vendor tools
protoc -I pkg:rpc:vendor --lint_out=. --go_out=pkg --twirp_out=pkg --gotemplate_out=single-package-mode=true,all=true:web/rpc rpc/todos/v1/*.proto
protoc -I pkg:rpc:vendor --lint_out=. --go_out=pkg --twirp_out=pkg --gotemplate_out=single-package-mode=true,all=true:web/rpc rpc/demo/*.proto
.PHONY: generate
tools: $(GO_TOOLS_DIR) $(GO_TOOLS_BIN)
@:
.PHONY: tools
$(GO_TOOLS_DIR):
@mkdir -p $@
$(GO_TOOLS_BIN):
GOBIN=${PWD}/${GO_TOOLS_DIR} go install ${GO_TOOLS}
bin/api: $(SOURCE)
go build -o $@ cmd/api/api.go
bin/web:
cd web && yarn build && yarn pkg
doc/index.html: $(RPC)
protoc -I pkg:rpc:vendor --doc_out=./doc --doc_opt=markdown,index.md $^