forked from siglens/siglens
-
Notifications
You must be signed in to change notification settings - Fork 0
/
package_siglens.sh
executable file
·101 lines (92 loc) · 3.73 KB
/
package_siglens.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
#! /bin/bash
# Extract the version number from pkg/config/version.go by getting everything
# inside the quotes. Use -n to supress printing each line, and p to print the
# modified line.
SIGLENS_VERSION=$(sed -n 's/const SigLensVersion = "\(.*\)"/\1/p' pkg/config/version.go)
platforms=("$(go env GOOS)/$(go env GOARCH)")
add_playground=""
while getopts p:b:g: flag
do
case "${flag}" in
p) IFS=',' read -r -a platforms <<< "${OPTARG}";;
g) add_playground="${OPTARG}";;
esac
done
echo "Compiling SigLens for ${platforms[@]}. Using version number ${SIGLENS_VERSION}, which was read from pkg/config/version.go. Uploading to S3 bucket=${upload_bucket}"
for platform in "${platforms[@]}"; do
platform_split=(${platform//\// })
export GOOS=${platform_split[0]}
export GOARCH=${platform_split[1]}
if [ ${GOOS} = "linux" ]; then
if [ ${GOARCH} = "amd64" ]; then
CC="zig cc -target x86_64-linux-gnu"
CXX="zig cc -target x86_64-linux-gnu"
export CC=$CC
export CXX=$CXX
export CGO_ENABLED=1
echo "Compiling SigLens for CGO_ENABLED=1, GOOS=${GOOS} and GOARCH=${GOARCH}."
go build -o siglens cmd/siglens/main.go
fi
if [ ${GOARCH} = "arm64" ]; then
CC="zig cc -target aarch64-linux-musl"
CXX="zig cc -target aarch64-linux-musl"
CGO_CFLAGS="-D_LARGEFILE64_SOURCE"
export CC=$CC
export CXX=$CXX
export CGO_ENABLED=1
export CGO_CFLAGS=$CGO_CFLAGS
echo "Compiling SigLens for CGO_ENABLED=1, GOOS=${GOOS} and GOARCH=${GOARCH}."
go build -o siglens cmd/siglens/main.go
fi
fi
if [ ${GOOS} = "darwin" ]; then
if [ ${GOARCH} = "arm64" ]; then
export CC=o64-clang
export CXX=o64-clang++
export CGO_CFLAGS="-arch ${GOARCH}"
export CGO_LDFLAGS="-arch ${GOARCH}"
export CFLAGS=-Qunused-arguments
export CPPFLAGS=-Qunused-arguments
export CGO_ENABLED=1
echo "Compiling SigLens for CGO_ENABLED=1, GOOS=${GOOS} and GOARCH=${GOARCH}"
go build -o siglens cmd/siglens/main.go
fi
if [ ${GOARCH} = "amd64" ]; then
export CC=o64-clang
export CXX=o64-clang++
export CGO_CFLAGS="-arch x86_64"
export CGO_LDFLAGS="-arch x86_64"
export CFLAGS=-Qunused-arguments
export CPPFLAGS=-Qunused-arguments
export CGO_ENABLED=1
export GOGCCFLAGS="-m64 -mthreads -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -gno-record-gcc-switches"
echo "Compiling SigLens for CGO_ENABLED=1, GOOS=${GOOS} and GOARCH=${GOARCH}"
go build -o siglens cmd/siglens/main.go
fi
fi
if [ $? -eq 0 ]
then
echo "Successfully built siglens binary for GOOS=${GOOS} and GOARCH=${GOARCH}"
else
echo "Could not create siglens binary for GOOS=${GOOS} and GOARCH=${GOARCH}"
exit 1
fi
dirname="siglens-${SIGLENS_VERSION}-${GOOS}-${GOARCH}/"
mkdir ${dirname}
mv siglens ${dirname}
cp -r static ${dirname}/
if [ "$add_playground" == "true" ]; then
echo "-----------------------------------------------------"
echo "using playground.yaml as config file"
cp playground.yaml ${dirname}
else
echo "-----------------------------------------------------"
echo "using server.yaml as config file"
cp server.yaml ${dirname}
fi
cp README.md ${dirname}
outputname="siglens-${SIGLENS_VERSION}-${GOOS}-${GOARCH}.tar.gz"
echo "Building tar archive at ${outputname}..."
tar -czf ${outputname} ${dirname}
rm -rf ${dirname}
done