| 1 |
DEPS = $(wildcard */*.go) |
| 2 |
BUILDVERSION = $(shell git describe --tags) |
| 3 |
BUILDTIME = $(shell date -u '+%Y-%m-%d_%H:%M:%S') |
| 4 |
UNAME := $(shell uname) |
| 5 |
|
| 6 |
all: test g10k |
| 7 |
|
| 8 |
g10k: g10k.go $(DEPS) |
| 9 |
# -race flag is currently removed because of issues in OS X Monterey. Should be solved above go version 1.17.6 |
| 10 |
ifeq ($(UNAME), Darwin) |
| 11 |
CGO_ENABLED=1 GOOS=darwin go build \ |
| 12 |
-ldflags "-s -w -X main.buildversion=${BUILDVERSION} -X main.buildtime=${BUILDTIME}" \ |
| 13 |
-o $@ |
| 14 |
strip -X $@ |
| 15 |
endif |
| 16 |
ifeq ($(UNAME), Linux) |
| 17 |
CGO_ENABLED=1 GOOS=linux go build \ |
| 18 |
-race -ldflags "-s -w -X main.buildversion=${BUILDVERSION} -X main.buildtime=${BUILDTIME}" \ |
| 19 |
-o $@ |
| 20 |
strip $@ |
| 21 |
endif |
| 22 |
|
| 23 |
lint: |
| 24 |
go install golang.org/x/lint/golint@latest && \ |
| 25 |
golint *.go |
| 26 |
|
| 27 |
vet: g10k.go |
| 28 |
go vet |
| 29 |
|
| 30 |
imports: g10k.go |
| 31 |
go install golang.org/x/tools/cmd/goimports@latest && \ |
| 32 |
goimports -d *.go tests/ |
| 33 |
|
| 34 |
test: lint vet imports |
| 35 |
# This is a workaround for Bug https://github.com/golang/go/issues/49138 |
| 36 |
ifeq ($(UNAME), Darwin) |
| 37 |
MallocNanoZone=0 go test -race -coverprofile=coverage.txt -covermode=atomic -v |
| 38 |
endif |
| 39 |
ifeq ($(UNAME), Linux) |
| 40 |
go test -race -coverprofile=coverage.txt -covermode=atomic -v ./... |
| 41 |
endif |
| 42 |
|
| 43 |
clean: |
| 44 |
rm -rf g10k coverage.txt cache example |
| 45 |
|
| 46 |
build-image: |
| 47 |
docker build -t g10k:${BUILDVERSION} . |
| 48 |
|
| 49 |
update-deps: |
| 50 |
go get -u |
| 51 |
go mod vendor |
| 52 |
|
| 53 |
.PHONY: all lint vet imports test clean |