-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.mk
65 lines (54 loc) · 1.48 KB
/
app.mk
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
GOPATH := $(shell go env GOPATH)
APP_VERSION := $(shell git describe --tags --always)
APP_RELATIVE_PATH := $(shell a=`basename $$PWD` && cd .. && b=`basename $$PWD` && echo $$b/$$a)
.PHONY: dep conf ent wire build clean run test
# generate config define code
conf:
@buf generate --path internal/conf --template internal/conf/buf.conf.gen.yaml
# download dependencies of module
dep:
@go mod download
# generate ent code
ent:
@if [ -d "./internal/data/ent" ]; then \
go run entgo.io/ent/cmd/ent generate \
--feature privacy \
--feature entql \
--feature sql/modifier \
--feature sql/execquery \
--feature sql/upsert \
./internal/data/ent/schema; \
fi
# generate wire code
wire:
@go run github.com/google/wire/cmd/wire ./cmd/server
# build golang application
build:
@if [ ! -d "./bin/" ]; then mkdir bin; fi
@go build -ldflags "-X main.Version=$(APP_VERSION)" -o ./bin/ ./...
# clean build files
clean:
@go clean
# run application
run:
@go run ./cmd/server -conf ./configs
# run tests
test:
@go test -v ./... -cover
# show help
help:
@echo ''
@echo 'Usage:'
@echo ' make [target]'
@echo ''
@echo 'Targets:'
@awk '/^[a-zA-Z\-\_0-9]+:/ { \
helpMessage = match(lastLine, /^# (.*)/); \
if (helpMessage) { \
helpCommand = substr($$1, 0, index($$1, ":")-1); \
helpMessage = substr(lastLine, RSTART + 2, RLENGTH); \
printf "\033[36m%-22s\033[0m %s\n", helpCommand,helpMessage; \
} \
} \
{ lastLine = $$0 }' $(MAKEFILE_LIST)
.DEFAULT_GOAL := help