-
-
Notifications
You must be signed in to change notification settings - Fork 45
/
Makefile
56 lines (45 loc) · 1.38 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
NAME=HellSpawner
GOCMD=LC_ALL=C go
TIMEOUT=5
# go tools
export PATH := ./bin:$(PATH)
export GO111MODULE := on
export GOPROXY = https://proxy.golang.org,direct
# go source files
SRC = $(shell find . -type f -name "*.go")
# The name of the executable (default is current directory name)
TARGET := $(shell echo $${PWD-`pwd`})
.PHONY: all build setup test cover clean run help
## all: Default target, now is build
all: build
## build: Builds the binary
build:
@echo "Building..."
@$(GOCMD) build -o ${NAME}
## setup: Runs mod download and generate
setup:
@echo "Downloading tools and dependencies..."
@git submodule update --init --recursive
@$(GOCMD) get -v -t -d ./...
@$(GOCMD) mod download -x
@$(GOCMD) get golang.org/x/tools/cmd/stringer
@$(GOCMD) install golang.org/x/tools/cmd/stringer
@$(GOCMD) generate -v ./...
## test: Runs the tests with coverage
test:
@echo "Running tests..."
@$(GOCMD) test -failfast -race -coverpkg=./... -covermode=atomic -coverprofile=coverage.txt ./... -run . -timeout $(TIMEOUT)m
## cover: Runs all tests and opens the coverage report in the browser
cover: test
@$(GOCMD) tool cover -html=coverage.txt
## clean: Runs go clean
clean:
@echo "Cleaning..."
@$(GOCMD) clean
## run: Runs go run
run: build
@$(GOCMD) run ${TARGET}
## help: Prints this help message
help:
@echo "Usage:"
@sed -n 's/^##//p' ${MAKEFILE_LIST} | column -t -s ':' | sed -e 's/^/ /'