-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
66 lines (51 loc) · 1.73 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
.PHONY: dev build generate install image release profile bench test clean setup
CGO_ENABLED=0
VERSION=$(shell git describe --abbrev=0 --tags)
COMMIT=$(shell git rev-parse --short HEAD)
BUILD=$(shell git show -s --pretty=format:%cI)
GOCMD=go
DESTDIR=/usr/local/bin
all: dev
dev: build
@./bitcask --version
@./bitcaskd --version
build: clean generate
@$(GOCMD) build \
-tags "netgo static_build" -installsuffix netgo \
-ldflags "-w -X $(shell go list)/internal.Version=$(VERSION) -X $(shell go list)/internal.Commit=$(COMMIT) -X $(shell go list)/internal.Build=$(BUILD)" \
./cmd/bitcask/...
@$(GOCMD) build \
-tags "netgo static_build" -installsuffix netgo \
-ldflags "-w -X $(shell go list)/internal.Version=$(VERSION) -X $(shell go list)/internal.Commit=$(COMMIT) -X $(shell go list)/internal.Build=$(BUILD)" \
./cmd/bitcaskd/...
generate:
@$(GOCMD) generate $(shell go list)/...
install: build
@install -D -m 755 bitcask $(DESTDIR)/bitcask
@install -D -m 755 bitcaskd $(DESTDIR)/bitcaskd
ifeq ($(PUBLISH), 1)
image:
@docker build --build-arg VERSION="$(VERSION)" --build-arg COMMIT="$(COMMIT)" -t prologic/bitcask .
@docker push prologic/bitcask
else
image:
@docker build --build-arg VERSION="$(VERSION)" --build-arg COMMIT="$(COMMIT)" -t prologic/bitcask .
endif
release:
@./tools/release.sh
profile: build
@$(GOCMD) test -cpuprofile cpu.prof -memprofile mem.prof -v -bench .
bench: build
@$(GOCMD) test -v -run=XXX -benchmem -bench=. .
mocks:
@mockery -all -case underscore -output ./internal/mocks -recursive
test: build
@$(GOCMD) test -v \
-cover -coverprofile=coverage.txt -covermode=atomic \
-coverpkg=$(shell go list) \
-race \
.
setup:
@$(GOCMD) get github.com/vektra/mockery/...
clean:
@git clean -f -d -X