forked from yorkie-team/yorkie
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
79 lines (62 loc) · 2.75 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
73
74
75
76
77
78
79
YORKIE_VERSION := 0.4.5
GO_PROJECT = github.com/yorkie-team/yorkie
ifeq ($(OS),Windows_NT)
BUILD_DATE := $(shell echo %date:~6,4%-%date:~0,2%-%date:~3,2%)
GO_SRC := $(shell dir /s /b *.go | findstr /v "vendor")
EXECUTABLE = ./bin/yorkie.exe
else
BUILD_DATE := $(shell date "+%Y-%m-%d")
GO_SRC := $(shell find . -path ./vendor -prune -o -type f -name '*.go' -print)
EXECUTABLE = ./bin/yorkie
endif
# inject the version number into the golang version package using the -X linker flag
GO_LDFLAGS ?=
GO_LDFLAGS += -X ${GO_PROJECT}/internal/version.Version=${YORKIE_VERSION}
GO_LDFLAGS += -X ${GO_PROJECT}/internal/version.BuildDate=${BUILD_DATE}
default: help
tools: ## install tools for developing yorkie
go install github.com/gogo/protobuf/[email protected]
go install github.com/gogo/protobuf/[email protected]
go install github.com/golangci/golangci-lint/cmd/[email protected]
proto: ## generate proto files
protoc \
-I=./api \
-I=$(GOPATH)/src \
--gofast_out=plugins=grpc,\
Mgoogle/protobuf/timestamp.proto=github.com/gogo/protobuf/types,\
Mgoogle/protobuf/wrappers.proto=github.com/gogo/protobuf/types,\
Mgoogle/protobuf/any.proto=github.com/gogo/protobuf/types,:./api/yorkie/v1 \
api/yorkie/v1/*.proto
protoset: ## generate protoset file
protoc \
-I=./api \
--descriptor_set_out=yorkie.protoset \
--include_imports \
api/yorkie/v1/*.proto
build: ## builds an executable that runs in the current environment
go build -o $(EXECUTABLE) -ldflags "${GO_LDFLAGS}" ./cmd/yorkie
build-binaries: ## builds binaries to attach a new release
rm -rf binaries
./build/build-binaries.sh $(YORKIE_VERSION) "$(GO_LDFLAGS)"
fmt: ## applies format and simplify codes
gofmt -s -w $(GO_SRC)
lint: ## runs the golang-ci lint, checks for lint violations
golangci-lint run ./...
test: ## runs integration tests that require local applications such as MongoDB
go clean -testcache
go test -tags integration -race ./...
bench: ## runs benchmark tests
rm -f pipe output.txt mem.prof cpu.prof bench.test
mkfifo pipe
tee output.txt < pipe &
go test -tags bench -benchmem -bench=. ./test/bench -memprofile=mem.prof -cpuprofile=cpu.prof > pipe
rm -f pipe
docker: ## builds docker images with the current version and latest tag
docker buildx build --push --platform linux/amd64,linux/arm64,linux/386 -t yorkieteam/yorkie:$(YORKIE_VERSION) -t yorkieteam/yorkie:latest .
docker-latest: ## builds docker images with latest tag
docker buildx build --push --platform linux/amd64,linux/arm64,linux/386 -t yorkieteam/yorkie:latest .
help:
@echo 'Commands:'
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf " %-20s %s\n", $$1, $$2}'
@echo
.PHONY: tools proto build build-binaries fmt lint test bench docker docker-latest help