forked from distributedio/titan
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
36 lines (27 loc) · 1.17 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
PROJECT_NAME := titan
PKG := github.com/meitu/$(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)
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=$(shell git log --abbrev-commit --oneline -n 1 | sed 's/$(GITHASH)//g')"
LDFLAGS += -X "$(PKG)/context.GitBranch=$(shell git rev-parse --abbrev-ref HEAD)"
.PHONY: all build clean test coverage lint proto
all: build
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/
clean:
rm -f ./titan
lint:
gometalinter --fast -t --errors --enable-gc ${GO_FILES}
proto:
cd ./db/zlistproto && protoc --gofast_out=plugins=grpc:. ./zlist.proto
release: build
./tools/release.sh