forked from WIttyJudge/adless
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
43 lines (31 loc) · 1004 Bytes
/
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
NAME=adless
SRC_PATH=./cmd/$(NAME)
BUILD_PATH=./build/$(NAME)
VERSION=$(shell git describe --abbrev=0 2>/dev/null || echo -n "unknown")
GIT_COMMIT=$(shell git rev-parse --short HEAD 2>/dev/null || echo -n "unknown")
BUILD_DATE=$(shell date +%FT%T%z)
LDFLAGS=-w -s \
-X main.version=$(VERSION) \
-X main.gitCommit=$(GIT_COMMIT) \
-X main.buildDate=$(BUILD_DATE)
.PHONY: run build test coverage clean
run:
go run $(SRC_PATH)
build: build-linux
build-linux:
GOOS=linux go build -ldflags "$(LDFLAGS)" -o $(BUILD_PATH) $(SRC_PATH)
build-windows:
GOOS=windows go build -ldflags "$(LDFLAGS)" -o $(BUILD_PATH).exe $(SRC_PATH)
build-darwin:
GOOS=darwin go build -ldflags "$(LDFLAGS)" -o $(BUILD_PATH).osx $(SRC_PATH)
test:
go test -v ./...
coverage:
go test ./... -coverprofile=coverage.out -covermode=atomic
go tool cover -html=coverage.out -o coverage.html
clean:
rm -rf ${BUILD_PATH}
rm -rf ${BUILD_PATH}.exe
rm -rf ${BUILD_PATH}.osx
rm -rf dist/
rm -f coverage.out coverage.html