-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
32 lines (25 loc) · 936 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
VERSION := 4.0
NAME := sdhash
BUILDSTRING := $(shell git log --pretty=format:'%h' -n 1)
VERSIONSTRING := $(VERSION)+$(BUILDSTRING)
OUTPUT = dist/$(NAME)
LDFLAGS := "-X \"main.Version=$(VERSIONSTRING)\""
GOFILES := $(wildcard app/*.go)
default: build
.PHONY: build
build: $(OUTPUT)
.PHONY: dist/$(NAME)
$(OUTPUT):
@mkdir -p dist/
go build -o $(OUTPUT) -ldflags=$(LDFLAGS) -v $(GOFILES)
clean:
rm -rf dist/
build_release: clean
GOOS=darwin GOARCH=amd64 go build -o "dist/$(NAME)-darwin-amd64" -ldflags=$(LDFLAGS) $(GOFILES)
GOOS=linux GOARCH=amd64 go build -o "dist/$(NAME)-linux-amd64" -ldflags=$(LDFLAGS) $(GOFILES)
GOOS=windows GOARCH=amd64 go build -o "dist/$(NAME)-windows-amd64" -ldflags=$(LDFLAGS) $(GOFILES)
GOOS=linux GOARCH=arm64 go build -o "dist/$(NAME)-linux-arm64" -ldflags=$(LDFLAGS) $(GOFILES)
test:
go test -v -coverprofile=coverage.txt -covermode=atomic .
coverage: test
go tool cover -html=coverage.txt