-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathMakefile
51 lines (38 loc) · 1.6 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
all: build
.PHONY: build linux_amd64 linux_arm64 clean lint race e2e test clean release
GINKGO:=go run github.com/onsi/ginkgo/ginkgo
REPO_DIR:=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
GIT_VERSION:=$(shell git tag --sort=-creatordate --points-at HEAD "${TAG_FILTER}*" | tail -n 1)
ifeq ($(GIT_VERSION),)
GIT_VERSION:=$(shell git describe --abbrev=0 --tags)
ifeq ($(GIT_VERSION),)
GIT_VERSION:=Build-Dev
else
GIT_VERSION:=$(GIT_VERSION)+Dev
endif
endif
GIT_BRANCH:=$(shell git rev-parse --abbrev-ref HEAD)
GIT_COMMIT:=$(shell git rev-parse --short=8 HEAD)
MAIN_VERSION_STR:=github.com/ymatrix-data/mxbench/internal/util.VersionStr=$(GIT_VERSION)
MAIN_BRANCH_STR:=github.com/ymatrix-data/mxbench/internal/util.BranchStr=$(GIT_BRANCH)
MAIN_COMMIT_STR:=github.com/ymatrix-data/mxbench/internal/util.CommitStr=$(GIT_COMMIT)
LDFLAGS:=-X $(MAIN_VERSION_STR) -X $(MAIN_BRANCH_STR) -X $(MAIN_COMMIT_STR)
build:
go build -o ./bin/mxbench -ldflags "$(LDFLAGS)" ./cmd/mxbench/main.go
linux_amd64:
env GOOS=linux GOARCH=amd64 go build -o ./bin/mxbench -ldflags "$(LDFLAGS)" ./cmd/mxbench/main.go
linux_arm64:
env GOOS=linux GOARCH=arm go build -o ./bin/mxbench -ldflags "$(LDFLAGS)" ./cmd/mxbench/main.go
release:
CGO_ENABLED=0 go build -o ./bin/mxbench -a -ldflags "$(LDFLAGS)" ./cmd/mxbench/main.go
clean:
rm -rf ./bin/*
lint:
golangci-lint -v run
test:
$(GINKGO) -race ./internal/...
e2e:
go build -tags e2e -ldflags "$(LDFLAGS)" -o mxbench_e2e ./cmd/mxbench
unset PGDATABASE; PATH="$(REPO_DIR):${PATH}" $(GINKGO) -tags e2e ./test/e2e/cli
race:
go build -race -ldflags "$(LDFLAGS)" -o mxbench_race ./cmd/mxbench