-
Notifications
You must be signed in to change notification settings - Fork 6
/
Makefile
33 lines (25 loc) · 1015 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
.PHONY: unit-test ticat
.DEFAULT_GOAL := default
REPO := github.com/innerr/ticat
GOOS := $(if $(GOOS),$(GOOS),$(shell go env GOOS))
GOARCH := $(if $(GOARCH),$(GOARCH),$(shell go env GOARCH))
GOENV := GO111MODULE=on CGO_ENABLED=0 GOOS=$(GOOS) GOARCH=$(GOARCH)
GO := $(GOENV) go
GOBUILD := $(GO) build $(BUILD_FLAG)
GOTEST := GO111MODULE=on CGO_ENABLED=1 go test -p 3
SHELL := /usr/bin/env bash
_COMMIT := $(shell git describe --no-match --always --dirty)
_GITREF := $(shell git rev-parse --abbrev-ref HEAD)
COMMIT := $(if $(COMMIT),$(COMMIT),$(_COMMIT))
GITREF := $(if $(GITREF),$(GITREF),$(_GITREF))
LDFLAGS := -w -s
LDFLAGS += -X "$(REPO)/pkg/version.GitHash=$(COMMIT)"
LDFLAGS += -X "$(REPO)/pkg/version.GitRef=$(GITREF)"
LDFLAGS += $(EXTRA_LDFLAGS)
FILES := $$(find . -name "*.go")
default: unit-test ticat
ticat:
$(GOBUILD) -ldflags '$(LDFLAGS)' -o bin/ticat ./pkg/main
unit-test:
mkdir -p bin/cover
$(GOTEST) ./pkg/... -covermode=count -coverprofile bin/cover/cov.unit-test.out