-
Notifications
You must be signed in to change notification settings - Fork 4
/
build.sh
executable file
·53 lines (43 loc) · 2.06 KB
/
build.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
#!/bin/bash
echo "----------------------------------------------------------------------"
echo " go get -u"
echo "----------------------------------------------------------------------"
go get -u ./...
echo "----------------------------------------------------------------------"
echo " go mod tidy"
echo "----------------------------------------------------------------------"
go mod tidy
mkdir -p bin/
rm bin/pgSimload*
echo "----------------------------------------------------------------------"
echo "Building binaries"
echo "----------------------------------------------------------------------"
echo "Building windows version, stripped executable (in bin/pgSimload_win.exe)"
GOOS=windows GOARCH=amd64 go build -ldflags "-s -w" -o bin/pgSimload_win.exe .
echo "Building mac (darwin) version, stripped executable (in bin/pgSimload_mac)"
GOOS=darwin GOARCH=amd64 go build -ldflags "-s -w" -o bin/pgSimload_mac .
echo "Building linux (amd64) version, stripped executable, not static (in bin/pgSimload)"
GOOS=linux GOARCH=amd64 go build -ldflags "-s -w" -o bin/pgSimload .
echo "Building linux (amd64) version, stripped executable, static (in bin/pgSimload_static)"
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -ldflags "-s -w" -o bin/pgSimload_static .
# --ldflags '-linkmode external -extldflags "-static"'
echo "----------------------------------------------------------------------"
echo "This script can copy the binary to /usr/local/bin if you want"
echo "It assumes user "`whoami`" is sudoer..."
echo "Proceed (y/n)?"
read REPLY
if [ $REPLY != "y" ]; then
echo "Exiting.."
exit 1
fi
echo "Do you want the static linux binary to be installed or the linked one?"
echo "Static version should work anywhere while the linked may not"
echo "Install static (s) or linked one (l) ? CTRL-C to abort"
read REPLY
if [ $REPLY = "l" ]; then
sudo cp -v bin/pgSimload /usr/local/bin
echo "Linked pgSimload binary installed in /usr/local/bin/pgSimload"
else
sudo cp -v bin/pgSimload_static /usr/local/bin/pgSimload
echo "Static pgSimload binary installed in /usr/local/bin/pgSimload"
fi