-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathMakefile
More file actions
47 lines (34 loc) · 893 Bytes
/
Makefile
File metadata and controls
47 lines (34 loc) · 893 Bytes
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
.PHONY: get build test fmt deploy run clean
PROJECT := csust-got
ifeq ($(VERSION),)
VERSION := $(if $(TAG),$(TAG),$(shell git rev-parse --short HEAD))
endif
ifeq ($(BRANCH),)
BRANCH := $(shell git branch --show-current)
endif
BUILDTIME := $(shell TZ="Asia/Shanghai" date '+%Y/%m/%d-%H:%M:%S')
FLAGPKG = $(PROJECT)/base
LDFLAGS = -s -w
LDFLAGS += -X $(FLAGPKG).version=$(VERSION)
LDFLAGS += -X $(FLAGPKG).branch=$(BRANCH)
LDFLAGS += -X $(FLAGPKG).buildTime=$(BUILDTIME)
CGOFLAG = 0
OUTPUT = got
get:
go get -v .
deps:
go mod download
build: get
CGO_ENABLED=$(CGOFLAG) \
go build -o $(OUTPUT) .
test:
go test -v -race -covermode=atomic -test.short ./...
fmt:
gofmt -l -w . && golangci-lint run
deploy:
CGO_ENABLED=$(CGOFLAG) \
go build -o $(OUTPUT) -ldflags "$(LDFLAGS)" .
run: deploy
./$(OUTPUT)
clean:
rm -f $(OUTPUT)