-
Notifications
You must be signed in to change notification settings - Fork 262
/
Makefile
84 lines (73 loc) · 2.49 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
78
79
80
81
82
83
84
# Go parameters
goCmd=go
version=$(shell cat VERSION)
goBuild=$(goCmd) build -ldflags "-X jiacrontab/pkg/version.Binary=$(version)"
goClean=$(goCmd) clean
goTest=$(goCmd) test
goGet=$(goCmd) get
sourceAdmDir=./app/jiacrontab_admin
sourceNodeDir=./app/jiacrontabd
binAdm=$(sourceAdmDir)/jiacrontab_admin
binNode=$(sourceNodeDir)/jiacrontabd
buildDir=./build
buildAdmDir=$(buildDir)/jiacrontab/jiacrontab_admin
buildNodeDir=$(buildDir)/jiacrontab/jiacrontabd
admCfg=$(sourceAdmDir)/jiacrontab_admin.ini
nodeCfg=$(sourceNodeDir)/jiacrontabd.ini
staticDir=./jiacrontab_admin/static/build
staticSourceDir=./jiacrontab_admin/static
workDir=$(shell pwd)
.PHONY: all build test clean build-linux build-windows
all: test build
build:
$(call checkStatic)
$(call init)
$(goBuild) -o $(binAdm) -v $(sourceAdmDir)
$(goBuild) -o $(binNode) -v $(sourceNodeDir)
mv $(binAdm) $(buildAdmDir)
mv $(binNode) $(buildNodeDir)
build2:
$(call init)
$(goBuild) -o $(binAdm) -v $(sourceAdmDir)
$(goBuild) -o $(binNode) -v $(sourceNodeDir)
mv $(binAdm) $(buildAdmDir)
mv $(binNode) $(buildNodeDir)
docker:
docker build \
-t iwannay/jiacrontab:$(version) \
-f Dockerfile \
.
test:
$(goTest) -v -race -coverprofile=coverage.txt -covermode=atomic $(sourceAdmDir)
$(goTest) -v -race -coverprofile=coverage.txt -covermode=atomic $(sourceNodeDir)
clean:
rm -f $(binAdm)
rm -f $(binNode)
rm -rf $(buildDir)
# Cross compilation
build-linux:
$(call checkStatic)
$(call init)
GOOS=linux GOARCH=amd64 $(goBuild) -o $(binAdm) -v $(sourceAdmDir)
GOOS=linux GOARCH=amd64 $(goBuild) -o $(binNode) -v $(sourceNodeDir)
mv $(binAdm) $(buildAdmDir)
mv $(binNode) $(buildNodeDir)
build-windows:
$(call checkStatic)
$(call init)
CGO_ENABLED=1 GOOS=windows GOARCH=amd64 CC="x86_64-w64-mingw32-gcc -fno-stack-protector -D_FORTIFY_SOURCE=0 -lssp" $(goBuild) -o $(binAdm).exe -v $(sourceAdmDir)
CGO_ENABLED=1 GOOS=windows GOARCH=amd64 CC="x86_64-w64-mingw32-gcc -fno-stack-protector -D_FORTIFY_SOURCE=0 -lssp" $(goBuild) -o $(binNode).exe -v $(sourceNodeDir)
mv $(binAdm).exe $(buildAdmDir)
mv $(binNode).exe $(buildNodeDir)
define checkStatic
@if [ "$(assets)" = "" ]; then echo "no assets, see https://github.com/jiacrontab/jiacrontab-frontend"; exit -1;else echo "build release"; fi
go-bindata -pkg admin -prefix $(assets) -o jiacrontab_admin/bindata_gzip.go -fs $(assets)/...
endef
define init
rm -rf $(buildDir)
mkdir $(buildDir)
mkdir -p $(buildAdmDir)
mkdir -p $(buildNodeDir)
cp $(admCfg) $(buildAdmDir)
cp $(nodeCfg) $(buildNodeDir)
endef