-
Notifications
You must be signed in to change notification settings - Fork 524
/
Copy pathMakefile
51 lines (36 loc) · 1.47 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
.PHONY: start build
NOW = $(shell date -u '+%Y%m%d%I%M%S')
RELEASE_VERSION = v10.1.0
APP = ginadmin
SERVER_BIN = ${APP}
GIT_COUNT = $(shell git rev-list --all --count)
GIT_HASH = $(shell git rev-parse --short HEAD)
RELEASE_TAG = $(RELEASE_VERSION).$(GIT_COUNT).$(GIT_HASH)
CONFIG_DIR = ./configs
CONFIG_FILES = dev
STATIC_DIR = ./build/dist
START_ARGS = -d $(CONFIG_DIR) -c $(CONFIG_FILES) -s $(STATIC_DIR)
all: start
start:
@go run -ldflags "-X main.VERSION=$(RELEASE_TAG)" main.go start $(START_ARGS)
build:
@go build -ldflags "-w -s -X main.VERSION=$(RELEASE_TAG)" -o $(SERVER_BIN)
build-linux:
CGO_ENABLED=1 GOOS=linux GOARCH=amd64 CC="zig cc -target x86_64-linux-musl" CXX="zig c++ -target x86_64-linux-musl" CGO_CFLAGS="-D_LARGEFILE64_SOURCE" go build -ldflags "-w -s -X main.VERSION=$(RELEASE_TAG)" -o $(SERVER_BIN)_linux_amd64
# go install github.com/google/wire/cmd/wire@latest
wire:
@wire gen ./internal/wirex
# go install github.com/swaggo/swag/cmd/swag@latest
swagger:
@swag init --parseDependency --generalInfo ./main.go --output ./internal/swagger
# https://github.com/OpenAPITools/openapi-generator
openapi:
docker run --rm -v ${PWD}:/local openapitools/openapi-generator-cli generate -i /local/internal/swagger/swagger.yaml -g openapi -o /local/internal/swagger/v3
clean:
rm -rf data $(SERVER_BIN)
serve: build
./$(SERVER_BIN) start $(START_ARGS)
serve-d: build
./$(SERVER_BIN) start $(START_ARGS) -d
stop:
./$(SERVER_BIN) stop