forked from operate-first/opfcli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
28 lines (21 loc) · 759 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
EXE = opfcli-$(shell go env GOOS)-$(shell go env GOARCH)
SRCS = $(shell find . -type f -name '*.go')
PKG = $(shell go list)
VERSION = $(shell git describe --tags --exact-match 2> /dev/null || echo unknown)
COMMIT = $(shell git rev-parse --short=10 HEAD)
DATE = $(shell date -u +"%Y-%m-%dT%H:%M:%S")
GOLDFLAGS = \
-X '$(PKG)/version.BuildVersion=$(VERSION)' \
-X '$(PKG)/version.BuildHash=$(COMMIT)' \
-X '$(PKG)/version.BuildDate=$(DATE)'
all: $(EXE)
$(EXE): $(SRCS)
go build -o $@ -ldflags "$(GOLDFLAGS)"
clean:
rm -f $(EXE) coverage.html coverage.txt coverage.out
coverage.html: coverage.out
go tool cover -html $< -o $@
coverage.txt: coverage.out
go tool cover -func $< -o $@
coverage.out: $(SRCS)
go test -coverprofile=$@ ./...