-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
53 lines (44 loc) · 1.5 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
# Version=`git describe --tags` # git tag 1.0.1 # require tag tagged before
GitVersion := 0.0.1
GitCommit := `git describe --abbrev=8 --dirty --always`
BuildTime := `date +%Y-%m-%d\ %H:%M`
BuildGoVersion := `go version`
BUILD_DIR := build
LDFLAGS := -X 'github.com/storvik/goshrt/version.GitVersion=${GitVersion}'
LDFLAGS += -X 'github.com/storvik/goshrt/version.GitCommit=${GitCommit}'
LDFLAGS += -X 'github.com/storvik/goshrt/version.BuildTime=${BuildTime}'
LDFLAGS += -X 'github.com/storvik/goshrt/version.BuildGoVersion=${BuildGoVersion}'
.PHONY: \
help \
all \
build \
clean \
lint \
test \
version \
vet
.DEFAULT_GOAL := build
clean: ## Clean project, run go clean and delete build/
rm -rf $(BUILD_DIR)
test: ## Run tests using go test
go test -v ./... -coverprofile=./cover.out -race -covermode=atomic -coverpkg=./...
lint: ## Run golint linter
golangci-lint run ./...
version: ## Print project version string
@echo "$(GitVersion)"
@echo "$(GitCommit)"
@echo "$(BuildTime)"
@echo "$(BuildGoVersion)"
build: ## Build application for current system
mkdir -p $(BUILD_DIR)/goshrt
mkdir -p $(BUILD_DIR)/goshrtc
go build -v \
-ldflags "-w -s $(LDFLAGS)" \
-o $(BUILD_DIR)/goshrt/goshrt \
cmd/goshrt/*.go
go build -v \
-ldflags "-w -s $(LDFLAGS)" \
-o $(BUILD_DIR)/goshrtc/goshrtc \
cmd/goshrtc/*.go
help: ## Display Makefile help
@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'