-
Notifications
You must be signed in to change notification settings - Fork 6
/
Makefile
71 lines (55 loc) · 1.84 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
SERVICE := baseca
BUILD := $(shell git rev-parse --short HEAD)
GITHUB_REPO := github.com/coinbase/baseca
TARGET=target
BIN=$(TARGET)/bin
LDFLAGS=-ldflags "-X=main.Version=$(VERSION) -X=main.Build=$(BUILD)"
.PHONY: usage
usage:
@ echo "Usage: make [`cat Makefile | grep "^[A-z\%\-]*:" | awk '{print $$1}' | sed "s/://g" | sed "s/%/[1-3]/g" | xargs`]"
.PHONY: info
info:
@ echo SERVICE: $(SERVICE)
@ echo BUILD: $(BUILD)
.PHONY: clean
clean: info
@ rm -rf target
.PHONY: dependencies
dependencies: info clean
@ go mod tidy
.PHONY: test
test: info clean dependencies
@ go test -v -cover -short $$(go list ./... | grep -v /examples)
.PHONY: build
build: info clean
@ GOOS=darwin GOARCH=amd64 go build $(LDFLAGS) -o $(BIN)/amd64/$(SERVICE) cmd/baseca/server.go
@ GOOS=darwin GOARCH=arm64 go build $(LDFLAGS) -o $(BIN)/arm64/$(SERVICE) cmd/baseca/server.go
.PHONY: build_amd64
build_amd64: info clean
@ GOOS=linux GOARCH=amd64 go build $(LDFLAGS) -o $(BIN)/linux/$(SERVICE) cmd/baseca/server.go
.PHONY: build_arm64
build_arm64: info clean
@ GOOS=linux GOARCH=arm64 go build $(LDFLAGS) -o $(BIN)/linux/$(SERVICE) cmd/baseca/server.go
.PHONY: sqlc
sqlc:
@ sqlc generate -f db/sqlc.yaml
.PHONY: mock
mock:
@ mockgen --build_flags=--mod=mod -package mock -destination db/mock/store.go ${GITHUB_REPO}/db/sqlc Store
.PHONY: gen
gen: info clean
@ buf generate protos --template protos/buf.gen.yaml
.PHONY: server
server:
@ database_credentials=${DATABASE_CREDENTIALS} \
go run cmd/baseca/server.go
.PHONY: lint
lint:
@ golangci-lint run
.PHONY: tools
tools:
@ go install go.uber.org/mock/mockgen@latest
@ go install google.golang.org/protobuf/cmd/[email protected]
@ go install google.golang.org/grpc/cmd/[email protected]
@ go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
@ which buf || (go install github.com/bufbuild/buf/cmd/buf@latest)