forked from cloudflare/circl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
56 lines (44 loc) · 1.36 KB
/
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
44
45
46
47
48
49
50
51
52
53
54
55
56
# I'm sure there is better way. But I would need to find it first
MK_FILE_PATH = $(lastword $(MAKEFILE_LIST))
PRJ_DIR = $(abspath $(dir $(MK_FILE_PATH)))
GOPATH_BUILD = $(PRJ_DIR)/build
COVER_DIR = $(GOPATH_BUILD)/coverage
TOOLS_DIR ?= $(GOPATH)/bin
ETC_DIR = $(PRJ_DIR)/.etc
OPTS ?=
NOASM ?=
GO ?= go
GOLANGCILINT ?= golangci-lint
# -run="^_" as we want to avoid running tests by 'bench' and there never be a test starting with _
BENCH_OPTS ?= -bench=. -run="^_" -benchmem
V ?= 1
GOARCH ?=
BUILD_ARCH = $(shell $(GO) env GOARCH)
ifeq ($(NOASM),1)
OPTS+=--tags noasm
endif
ifeq ($(V),1)
OPTS += -v # Be verbose
endif
all: build
lint:
$(GOLANGCILINT) run --config $(ETC_DIR)/golangci.yml ./...
lint-fix:
$(GOLANGCILINT) run --config $(ETC_DIR)/golangci.yml --fix ./...
build:
$(GO) build ./...
test: clean
$(GO) vet ./...
$(GO) test $(OPTS) ./...
bench: clean
$(GO) test $(BENCH_OPTS) $(OPTS) ./...
cover: clean
mkdir -p $(COVER_DIR)
$(GO) test -race -coverprofile=$(COVER_DIR)/coverage.txt -covermode=atomic $(OPTS) ./...
$(GO) tool cover -html $(COVER_DIR)/coverage.txt -o $(COVER_DIR)/coverage.html
generate: clean
$(GO) generate -v ./...
bootstrap:
curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(TOOLS_DIR) v1.18.0
clean:
rm -rf $(GOPATH_BUILD)