-
Notifications
You must be signed in to change notification settings - Fork 5
/
makefile
72 lines (56 loc) · 2.13 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
# this makefile used in console environment.
# copy this file to project base directory.
# SET BIN NAME BY USER
binName:=pgo2-demo
goBin:=go
######## DO NOT CHANGE THE FLOWING CONTENT ########
# absolute path of makefile
mkPath:=$(abspath $(firstword $(MAKEFILE_LIST)))
# absolute base directory of project
baseDir:=$(strip $(patsubst %/, %, $(dir $(mkPath))))
binDir:=$(baseDir)/bin
pkgDir:=$(baseDir)/pkg
.PHONY: start stop build update pgo2 init
start: build
$(binDir)/$(binName)
stop:
-killall $(binName)
build:
[ -d $(binDir) ] || mkdir $(binDir)
$(goBin) build -o $(binDir)/$(binName) $(baseDir)/cmd/$(binName)/main.go
update:
cd $(baseDir) && $(goBin) get
install:
cd $(baseDir) && $(goBin) mod download
pgo2:
cd $(baseDir) && $(goBin) get -u github.com/pinguo/pgo2
vendor:
cd $(baseDir) && $(goBin) mod vendor
init:
[ -d $(baseDir)/cmd ] || mkdir $(baseDir)/cmd
[ -d $(baseDir)/runtime ] || mkdir $(baseDir)/runtime
[ -d $(baseDir)/cmd/$(binName) ] || mkdir $(baseDir)/cmd/$(binName)
[ -d $(baseDir)/web ] || mkdir $(baseDir)/web
[ -d $(baseDir)/web/template ] || mkdir $(baseDir)/web/template
[ -d $(baseDir)/web/static ] || mkdir $(baseDir)/web/static
[ -d $(baseDir)/configs ] || mkdir $(baseDir)/configs
[ -d $(baseDir)/assets ] || mkdir $(baseDir)/assets
[ -d $(baseDir)/build ] || mkdir $(baseDir)/build
[ -d $(pkgDir) ] || mkdir $(pkgDir)
[ -d $(pkgDir)/command ] || mkdir $(pkgDir)/command
[ -d $(pkgDir)/controller ] || mkdir $(pkgDir)/controller
[ -d $(pkgDir)/lib ] || mkdir $(pkgDir)/lib
[ -d $(pkgDir)/model ] || mkdir $(pkgDir)/model
[ -d $(pkgDir)/service ] || mkdir $(pkgDir)/service
[ -d $(pkgDir)/structs ] || mkdir $(pkgDir)/structs
[ -d $(pkgDir)/test ] || mkdir $(pkgDir)/test
[ -f $(pkgDir)/go.mod ] || (cd $(baseDir) && $(goBin) mod init $(binName))
help:
@echo "make start build and start $(binName)"
@echo "make stop stop process $(binName)"
@echo "make build build $(binName)"
@echo "make update go mod get"
@echo "make install go mod download"
@echo "make pgo2 go mod get -u pgo2"
@echo "make init init project"
@echo "make vendor go mod vendor"