-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
49 lines (40 loc) · 1.44 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
GIT_REV?=$$(git rev-parse --short HEAD)
DATE?=$$(date -u +"%Y-%m-%dT%H:%M:%SZ")
VERSION?=$$(git describe --tags --always)
LDFLAGS="-s -w -X main.version=$(VERSION)-$(GIT_REV) -X main.date=$(DATE)"
goos?=${INPUT_GOOS}
goarch?=${INPUT_GOARCH}
NAME:=mandel
GREEN := $(shell tput -Txterm setaf 2)
YELLOW := $(shell tput -Txterm setaf 3)
CYAN := $(shell tput -Txterm setaf 6)
RESET := $(shell tput -Txterm sgr0)
.PHONY: default help
default: help
## Build:
prepare: ## Download depencies and prepare dev env
@pre-commit install
@go mod download
@go mod vendor
build: ## Builds the game
@CGO_ENABLED=1 go build -ldflags=$(LDFLAGS) -o ./bin/$(NAME) .
buildwin: ## Builds game for Win64
@CC=x86_64-w64-mingw32-gcc GOOS=windows GOARCH=amd64 CGO_ENABLED=1 go build -ldflags=$(LDFLAGS) -o ./bin/$(NAME).exe .
build-ci: ## Optimized build for CI
@echo $(goos)/$(goarch)
@GOOS=$(goos) GOARCH=$(goarch) CGO_ENABLED=1 go build -ldflags=$(LDFLAGS) -o ./bin/$(NAME)_$(goos)_$(goarch) .
## Test:
coverage: ## Run test coverage suite
@go test ./... --coverprofile=cov.out
@go tool cover --html=cov.out
## Help:
help: ## Show this help.
@echo ''
@echo 'Usage:'
@echo ' ${YELLOW}make${RESET} ${GREEN}<target>${RESET}'
@echo ''
@echo 'Targets:'
@awk 'BEGIN {FS = ":.*?## "} { \
if (/^[a-zA-Z_-]+:.*?##.*$$/) {printf " ${YELLOW}%-20s${GREEN}%s${RESET}\n", $$1, $$2} \
else if (/^## .*$$/) {printf " ${CYAN}%s${RESET}\n", substr($$1,4)} \
}' $(MAKEFILE_LIST)