~nromdotcom/gemif

ref: 7428380780749a75318cfc276c3197263d72e829 gemif/Makefile -rw-r--r-- 3.7 KiB
74283807Norm MacLennan Update infrastructure dependencies 9 months ago
                                                                                
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
.PHONY: help build clean build-all package release
.DEFAULT_GOAL := help

pkg_root = git.sr.ht/~nromdotcom/gemif

### Calculate a few variables for use in building and deploying the app
VERSION = $(shell git describe --tags --always)
COMMIT = $(shell git log --pretty='format:%h' -n 1)
BUILDDATE = $(shell date +"%Y.%m.%d.%H%M%S")
# ldflags inject new values into variables at compilation time
# this is how we dynamically set the version/etc of the application
ldflags = "-X 'main.appVersion=$(VERSION)' \
	-X 'main.appCommit=$(COMMIT)' \
	-X 'main.buildTime=$(BUILDDATE)' \
	-w -s"

##@ Help
help:  ## Display this help
	@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n  make \033[36m<target>\033[0m\n"} /^[a-zA-Z_-]+:.*?##/ { printf "  \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)

##@ Utilities
init: ## Install utils
	go mod download

run: ## go-run locally (optional args="")
	go run git.sr.ht/~nromdotcom/gemif/cmd/gemif

air: ## run app with live reloading
	rm -f cmd/gemif/pkged.go
	air -c .air.toml

tidy_deps: ## Remove unused dependencies
	go mod tidy

upgrade_deps: ## Upgrade versions of dependencies
	go get -u

##@ Build
gemif-build: clean ## Build GemIF server for your native architecture
	go build -o ./bin/gemif -ldflags=$(ldflags) $(pkg_root)/cmd/gemif

gemif-build-all: clean ## Build GemIF server for linux and mac
	GOOS=darwin GOARCH=amd64 go build -o ./bin/gemif-darwin-amd64/gemif -ldflags=$(ldflags) $(pkg_root)/cmd/gemif
	GOOS=darwin GOARCH=arm64 go build -o ./bin/gemif-darwin-arm64/gemif -ldflags=$(ldflags) $(pkg_root)/cmd/gemifc
	GOOS=linux GOARCH=amd64 go build -o ./bin/gemif-linux-amd64/gemif -ldflags=$(ldflags) $(pkg_root)/cmd/gemif
	GOOS=linux GOARCH=arm64 go build -o ./bin/gemif-linux-arm64/gemif -ldflags=$(ldflags) $(pkg_root)/cmd/gemif

gemifc-build: clean ## Build story copiler for your native architecture
	go build -o ./bin/gemifc -ldflags=$(ldflags) $(pkg_root)/cmd/gemifc

gemifc-build-all: clean ## Build story compiler for linux and mac
	GOOS=darwin GOARCH=amd64 go build -o ./bin/gemif-darwin-amd64/gemifc -ldflags=$(ldflags) $(pkg_root)/cmd/gemifc
	GOOS=darwin GOARCH=arm64 go build -o ./bin/gemif-darwin-arm64/gemifc -ldflags=$(ldflags) $(pkg_root)/cmd/gemifc
	GOOS=linux GOARCH=amd64 go build -o ./bin/gemif-linux-amd64/gemifc -ldflags=$(ldflags) $(pkg_root)/cmd/gemifc
	GOOS=linux GOARCH=arm64 go build -o ./bin/gemif-linux-arm64/gemifc -ldflags=$(ldflags) $(pkg_root)/cmd/gemifc

build: gemif-build gemifc-build ## Build gemif and gemifc for native architecture
build-all: gemif-build-all gemifc-build-all ## Build gemif and gemifc for linux and mac

clean: ## Delete any compiled artifacts
	rm -rf ./bin

protobuf: ## until i can reliably re-generate this, separate it from generate
	protoc -I pkg/ --go_out=. pkg/gamemanager/statetoken.proto

##@ Deploy
package: build-all ## Build everything and package up arch-specific tarballs
	tar czvf ./bin/gemif-darwin-amd64.tar.gz ./bin/gemif-darwin-amd64
	tar czvf ./bin/gemif-darwin-arm64.tar.gz ./bin/gemif-darwin-arm64
	tar czvf ./bin/gemif-linux-amd64.tar.gz ./bin/gemif-linux-amd64
	tar czvf ./bin/gemif-linux-arm64.tar.gz ./bin/gemif-linux-arm64

release: package ## Attach packages to sr.ht ref for current tag
	./scripts/release_version.sh

##@ Test
test: ## Run tests
	go test $(shell go list ./...) -coverprofile=coverage.out
	go tool cover -func=coverage.out

nonmegalint: ## do a regular golint
	golint $(shell go list ./...)

megalint: ## Run several linters in parallel (requires docker)
	docker run --rm -v $(PWD):/app -w /app golangci/golangci-lint:v1.36.0 golangci-lint run

# Non-docker golangci-lint for running in CI without docker available
megalintci:
	golangci-lint run