-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
42 lines (30 loc) · 1.08 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
VERSION := v1.0.0
PROJECT := github.com/amazingchow/consistent-hashing-service-provider
SRC := $(shell find . -type f -name '*.go' -not -path "./vendor/*")
TARGETS := consistent-hashing-service-provider
ALL_TARGETS := $(TARGETS)
LDFLAGS += -X "$(PROJECT)/internal/version.Version=$(VERSION)"
LDFLAGS += -X "$(PROJECT)/internal/version.GitBranch=$(shell git rev-parse --abbrev-ref HEAD)"
LDFLAGS += -X "$(PROJECT)/internal/version.GitHash=$(shell git rev-parse HEAD)"
LDFLAGS += -X "$(PROJECT)/internal/version.BuildTS=$(shell date -u '+%Y-%m-%d %I:%M:%S')"
ifeq ($(race), 1)
BUILD_FLAGS := -race
endif
ifeq ($(debug), 1)
BUILD_FLAGS += -gcflags=all="-N -l"
endif
compile_pb:
@docker run --rm -v `pwd`:/defs namely/protoc-all:1.37_0 -o pb -d pb -l go
all: build
build: $(ALL_TARGETS)
$(TARGETS): $(SRC)
go build $(BUILD_FLAGS) -ldflags '$(LDFLAGS)' $(PWD)/cmd/$@
lint:
@golangci-lint run --skip-dirs=api --deadline=5m
pb-fmt:
@clang-format -i ./pb/*.proto
test:
go test -count=1 -v -p 1 $(shell go list ./...)
clean:
rm -f $(ALL_TARGETS)
.PHONY: all build clean