-
Notifications
You must be signed in to change notification settings - Fork 118
/
Makefile
41 lines (31 loc) · 1.38 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
PROJECT_NAME := titan
PKG := github.com/distributedio/$(PROJECT_NAME)
PKG_LIST := $(shell go list ${PKG}/... | grep -v /vendor/)
GITHASH := $(shell git rev-parse --short HEAD)
GO_FILES := $(shell find . -name '*.go' | grep -v /vendor/ | grep -v _test.go)
GO_LOGS := $(shell git log --abbrev-commit --oneline -n 1 | sed 's/$(GITHASH)//g' | sed 's/"//g' | sed "s/'//g")
LDFLAGS += -X "$(PKG)/context.ReleaseVersion=$(shell git tag --contains)"
LDFLAGS += -X "$(PKG)/context.BuildTS=$(shell date -u '+%Y-%m-%d %I:%M:%S')"
LDFLAGS += -X "$(PKG)/context.GitHash=$(GITHASH)"
LDFLAGS += -X "$(PKG)/context.GolangVersion=$(shell go version)"
LDFLAGS += -X "$(PKG)/context.GitLog=$(GO_LOGS)"
LDFLAGS += -X "$(PKG)/context.GitBranch=$(shell git rev-parse --abbrev-ref HEAD)"
.PHONY: all build clean test coverage lint proto
all: build token
test:
env GO111MODULE=on go test -short ${PKG_LIST}
coverage:
env GO111MODULE=on go test -covermode=count -v -coverprofile cover.cov ${PKG_LIST}
build:
env GO111MODULE=on go build -ldflags '$(LDFLAGS)' -o titan ./bin/titan/
token: tools/token/main.go command/common.go
env GO111MODULE=on go build -ldflags '$(LDFLAGS)' -o token ./tools/token/
clean:
rm -f ./titan
rm -rf ./token
lint:
golangci-lint run -p=bugs,complexity,format,performance,style,unused
proto:
cd ./db/zlistproto && protoc --gofast_out=plugins=grpc:. ./zlist.proto
release: build
./tools/release.sh