-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
77 lines (54 loc) · 1.69 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
BIN_DIR = bin
EXE =
GO_BUILD_FLAGS = -trimpath -ldflags '-s -w' -o "$(BIN_DIR)/$(BINARY)"
IS_LINUX = false
ifeq ($(OS),Windows_NT)
EXE = .exe
else
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Linux)
IS_LINUX = true
endif
endif
BINARY = server$(EXE)
ifeq ($(IS_LINUX),true)
GO_BUILD_FLAGS = -tags 'osusergo netgo static_build sqlite_omit_load_extension sqlite_foreign_keys' -trimpath -ldflags '-linkmode "external" -s -w -extldflags "-fno-PIC -static"' -o "$(BIN_DIR)/$(BINARY)"
endif
.PHONY: build frontend build-production build-test unit-test dependencies dev fmt desc gen ent-gen swag-gen
build:
go build -o "$(BIN_DIR)/$(BINARY)" github.com/ZNotify/server
app/api/web/static/index.html:
go run github.com/ZNotify/server/scripts download
frontend: app/api/web/static/index.html
build-production: frontend
go build $(GO_BUILD_FLAGS) github.com/ZNotify/server
build-test: frontend
go build -tags test -o "$(BIN_DIR)/$(BINARY)" github.com/ZNotify/server
build-analysis: frontend
go build -gcflags="all=-N -l" -o "$(BIN_DIR)/$(BINARY)" github.com/ZNotify/server
unit-test: frontend
go test -v -tags test ./...
dependencies:
go mod vendor
go install github.com/swaggo/swag/cmd/swag@master
go install github.com/cosmtrek/air@latest
go install entgo.io/ent/cmd/ent@latest
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
dev:
air
fmt:
swag fmt
go fmt ./...
desc:
go run -mod=mod entgo.io/ent/cmd/ent describe ./schema
ent-gen:
go run github.com/ZNotify/server/scripts ent
swag-gen:
swag init
schema-gen:
go run -tags schema github.com/ZNotify/server/scripts schema
gen: ent-gen swag-gen schema-gen
lint:
golangci-lint run
analyze:
go tool nm "$(BIN_DIR)/$(BINARY)"