-
Notifications
You must be signed in to change notification settings - Fork 3
/
build_napval.sh
executable file
·131 lines (116 loc) · 2.58 KB
/
build_napval.sh
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#!/bin/bash
set -e
CWD=`pwd`
echo "Downloading CORE.json"
#curl https://raw.githubusercontent.com/nsip/registration-data-set/master/core.json > app/napval/schemas/core.json
#curl https://raw.githubusercontent.com/nsip/registration-data-set/master/core_parent2.json > app/napval/schemas/core_parent2.json
echo "Downloading nats-streaming-server"
# go get github.com/nats-io/nats-streaming-server
# go get github.com/nats-io/stan.go
rm -rf nats-streaming-server
git clone https://github.com/nats-io/nats-streaming-server
cd nats-streaming-server
cd ..
do_build() {
echo "Building NAPVAL..."
mkdir -p $OUTPUT
rm -rf $OUTPUT/*.csv
cd nats-streaming-server
# cd ../../nats-io/stan.go
GOOS="$GOOS" GOARCH="$GOARCH" go build -ldflags="$LDFLAGS" -o $OUTPUT/$GNATS -mod=mod
cd $CWD
cd ./app/napval
go get
GOOS="$GOOS" GOARCH="$GOARCH" go build -ldflags="$LDFLAGS" -o $OUTPUT/$HARNESS -mod=mod
cd ..
rsync -a napval/napval.toml napval/napval_nss.cfg napval/public napval/schemas napval/schoolslist napval/templates $OUTPUT/
rsync -a napval/students.csv $OUTPUT/
}
do_shells() {
cd $CWD
cp bin/gonapval.sh $OUTPUT/
cp bin/stopnapval.sh $OUTPUT/
}
do_bats() {
cd $CWD
cp bin/gonapval.bat $OUTPUT/
cp bin/stopnapval.bat $OUTPUT/
}
do_upx() {
upx $OUTPUT/$GNATS
upx $OUTPUT/$HARNESS
}
do_goupx() {
goupx $OUTPUT/$GNATS
goupx $OUTPUT/$HARNESS
}
do_zip() {
cd $OUTPUT
cd ..
#zip -qr ../$ZIP napval
cd $CWD
}
build_mac64() {
# MAC OS X (64 only)
echo "Building Mac binaries..."
GOOS=darwin
GOARCH=amd64
LDFLAGS="-s -w"
OUTPUT=$CWD/build/Mac/napval
GNATS=nats-streaming-server
HARNESS=napval
ZIP=nias-napval-Mac.zip
do_build
#do_upx
do_shells
# do_zip
echo "...all Mac binaries built..."
}
build_windows64() {
# WINDOWS 64
echo "Building Windows64 binaries..."
GOOS=windows
GOARCH=amd64
LDFLAGS="-s -w"
OUTPUT=$CWD/build/Win64/napval
GNATS=nats-streaming-server.exe
HARNESS=napval.exe
ZIP=nias-napval-Win64.zip
do_build
#do_upx
do_bats
# do_zip
echo "...all Windows64 binaries built..."
}
build_linux64() {
# LINUX 64
echo "Building Linux64 binaries..."
GOOS=linux
GOARCH=amd64
LDFLAGS="-s -w"
OUTPUT=$CWD/build/Linux64/napval
GNATS=nats-streaming-server
HARNESS=napval
ZIP=nias-napval-Linux64.zip
do_build
#do_goupx
do_shells
# do_zip
echo "...all Linux64 binaries built..."
}
# TODO ARM
# GOOS=linux GOARCH=arm GOARM=7 go build -o $CWD/build/LinuxArm7/go-nias/aggregator
if [ "$1" = "L64" ]
then
build_linux64
elif [ "$1" = "W64" ]
then
build_windows64
elif [ "$1" = "M64" ]
then
build_mac64
else
build_mac64
build_windows64
build_linux64
fi