-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
62 lines (47 loc) · 1.33 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
57
58
59
60
61
62
VERSION := devel
TARGET_EXE_NAME := stg.exe
TARGET_ZIP_NAME := stg-$(VERSION).zip
TARGET_OS := windows
TARGET_ARCH := amd64
BIN_DIR := $(CURDIR)/bin
OUT_DIR := $(CURDIR)/out
GOIMPORTS := $(BIN_DIR)/goimports
STATICCHECK := $(BIN_DIR)/staticcheck
.PHONY: all
all: build
## Basic
.PHONY: setup
setup: ## Setup necessary tools.
mkdir -p $(BIN_DIR)
GOBIN=$(BIN_DIR) go install golang.org/x/tools/cmd/goimports@latest
GOBIN=$(BIN_DIR) go install honnef.co/go/tools/cmd/staticcheck@latest
.PHONY: clean
clean: ## Clean files.
rm -rf $(OUT_DIR)/*
.PNOHY: distclean
distclean: clean ## Clean all files.
rm -rf $(BIN_DIR)/*
-rmdir $(BIN_DIR) $(OUT_DIR)
## Build
.PHONY: build
build:
GOOS=$(TARGET_OS) GOARCH=$(TARGET_ARCH) go build -trimpath -ldflags "-s -w -X main.version=$(VERSION)" -o $(OUT_DIR)/$(TARGET_EXE_NAME) ./cmd/game
.PHONY: zip
zip:
zip -j $(OUT_DIR)/$(TARGET_ZIP_NAME) $(OUT_DIR)/$(TARGET_EXE_NAME)
## Test
.PHONY: check-generate
check-generate: ## Generate code, and check if diff exists.
GOOS=$(TARGET_OS) GOARCH=$(TARGET_ARCH) go mod tidy
git diff --exit-code --name-only
.PHONY: lint
lint:
test -z "$$($(GOIMPORTS) -l $$(find . -name '*.pb.go' -prune -o -name '*.go' -print) | tee /dev/stderr)"
$(STATICCHECK) ./...
go vet ./...
.PHONY: test
test:
go test -v ./...
.PHONY: run
run:
$(OUT_DIR)/$(TARGET_EXE_NAME) -debug