2022-09-20 15:50:01 +00:00
|
|
|
PROJECTNAME=server.exe
|
|
|
|
ROOT_DIR=.
|
2022-12-18 08:48:33 +00:00
|
|
|
#GOPROXY=https://mirrors.aliyun.com/goproxy
|
|
|
|
GOPROXY=https://goproxy.io
|
2022-09-20 15:50:01 +00:00
|
|
|
all: help
|
|
|
|
|
2023-02-19 05:42:25 +00:00
|
|
|
# To install `gojson` executable
|
|
|
|
# ```
|
|
|
|
# go install github.com/ChimeraCoder/gojson/gojson@latest
|
|
|
|
# ```
|
|
|
|
#
|
|
|
|
# OS detection reference https://stackoverflow.com/a/12099167
|
2022-09-20 15:50:01 +00:00
|
|
|
gen-constants:
|
|
|
|
gojson -pkg common -name constants -input common/constants.json -o common/constants_struct.go
|
2023-02-19 05:42:25 +00:00
|
|
|
ifeq ($(OS),Windows_NT)
|
2022-09-20 15:50:01 +00:00
|
|
|
sed -i 's/int64/int/g' common/constants_struct.go
|
2023-02-19 05:42:25 +00:00
|
|
|
else
|
|
|
|
UNAME_S := $(shell uname -s)
|
|
|
|
ifeq ($(UNAME_S),Darwin)
|
|
|
|
sed -i '' -e 's/int64/int/g' common/constants_struct.go
|
|
|
|
else
|
|
|
|
sed -i 's/int64/int/g' common/constants_struct.go
|
|
|
|
endif
|
|
|
|
endif
|
2022-09-20 15:50:01 +00:00
|
|
|
|
|
|
|
run-test: build
|
|
|
|
ServerEnv=TEST ./$(PROJECTNAME)
|
|
|
|
|
|
|
|
run-test-and-hotreload:
|
|
|
|
ServerEnv=TEST CompileDaemon -log-prefix=false -build="go build" -command="./$(PROJECTNAME)"
|
|
|
|
|
|
|
|
build:
|
2022-11-28 15:49:46 +00:00
|
|
|
GOPROXY=$(GOPROXY) go build -o $(ROOT_DIR)/$(PROJECTNAME)
|
2022-09-20 15:50:01 +00:00
|
|
|
|
|
|
|
run-prod: build-prod
|
|
|
|
./$(PROJECTNAME)
|
|
|
|
|
|
|
|
build-prod:
|
2022-11-28 15:49:46 +00:00
|
|
|
GOPROXY=$(GOPROXY) go build -ldflags "-s -w -X main.VERSION=$(shell git rev-parse --short HEAD)-$(shell date "+%Y%m%d-%H:%M:%S")" -o $(ROOT_DIR)/$(PROJECTNAME)
|
2022-09-20 15:50:01 +00:00
|
|
|
|
|
|
|
.PHONY: help
|
|
|
|
|
|
|
|
help: Makefile
|
|
|
|
@echo
|
|
|
|
@echo " Choose a command run:"
|
|
|
|
@echo
|
|
|
|
@sed -n 's/^##//p' $< | column -t -s ':' | sed -e 's/^/ /'
|
|
|
|
@echo
|
|
|
|
|