-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Makefile
79 lines (64 loc) · 2.8 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
GOVERSION ?= 1.20
ROOT_DIR=${PWD}
HARDWARE=$(shell uname -m)
GIT_SHA=$(shell git --no-pager describe --always --dirty| cut -c1-7)
GIT_BRANCH=$(shell git rev-parse --abbrev-ref HEAD)
BUILD_TIME=$(shell date '+%s')
#VERSION ?= $(shell awk '/Release.*=/ { print $$3 }' version/version.go | sed 's/"//g')
ARCHITECTURES=amd64
HOST=$(shell hostname)
DOC_PACKAGE=github.com/paalgyula/summit/docs
LFLAGS ?= -X ${DOC_PACKAGE}.Gitsha=${GIT_SHA} \
-X ${DOC_PACKAGE}.Version=prod \
-X ${DOC_PACKAGE}.Compiled=${BUILD_TIME} \
-X ${DOC_PACKAGE}.Buildhost=${HOST} \
-X ${DOC_PACKAGE}.Branch=${GIT_BRANCH}
TAGS?=netgo
BUILDCMD=CGO_ENABLED=0 GOOS=linux go build -a -tags ${TAGS} -ldflags "-s -w ${LFLAGS}"
default: build
## Install dependencies required for code generating
deps:
go install google.golang.org/protobuf/cmd/[email protected]
go install golang.org/x/tools/cmd/stringer@latest
go install github.com/josharian/impl@latest
## Generates interface stubs
gen:
@echo "Generating database interface stubs"
@cd pkg/store/localdb && impl 'db *LocalStore' store.AccountRepo >> localstore.go
@cd pkg/store/localdb && impl 'db *LocalStore' store.CharacterRepo >> localstore.go
@cd pkg/store/localdb && impl 'db *LocalStore' store.WorldRepo >> localstore.go
@cd pkg/store/mysqldb && impl 'store *AccountStore' store.AccountRepo >> accountstore.go
@cd pkg/store/mysqldb && impl 'store *CharacterStore' store.CharacterRepo >> characterstore.go
@cd pkg/store/mysqldb && impl 'store *WorldStore' store.WorldRepo >> worldstore.go
@echo "Generating world server interface stubs"
@cd pkg/summit/world && impl 'ws *Server' world.SessionManager >> sessionmanager.go
@echo "Generating auth server interface stubs"
@cd pkg/summit/auth && impl 'ms *ManagementServiceImpl' ManagementService >> management.go
@cd pkg/summit/auth && impl 'mc *ManagementClient' ManagementService >> management_client.go
@go install cmd/datagen/datagen.go
@go generate ./...
clean:
rm -Rf bin/*
lint:
@echo "--> Linting the project with golangci-lint..."
@golangci-lint run ./...
build:
@echo "--> Compiling the project"
@mkdir -p bin/
go build -o bin/summit cmd/summit/summit.go
go build -o bin/serworm cmd/serworm/serworm.go
go build -o bin/datagen cmd/datagen/datagen.go
build-dist: clean
@mkdir -p bin/
@echo "--> Compiling world server"
@$(BUILDCMD) -o bin/summit cmd/summit/summit.go
@echo "--> Compiling serworm"
@$(BUILDCMD) -o bin/serworm cmd/serworm/serworm.go
@echo "--> Compiling datagen"
@$(BUILDCMD) -o bin/datagen cmd/datagen/datagen.go
@echo "Done. You can find the compiled binaries in the bin/ folder"
## Installs dependencies (summit code generation tools) to go's bin folder. Usually to $HOME/go/bin
install:
@echo "Installing summit tools..."
@go install cmd/datagen/datagen.go
@go install cmd/summitctl/summitctl.go