-
-
Notifications
You must be signed in to change notification settings - Fork 12
/
build
executable file
·67 lines (50 loc) · 1.48 KB
/
build
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
#!/bin/bash
# The basename of our binary
BASE="overseer"
# Save our directory, since we build in child-directories later.
D=$(pwd)
#
# We build on multiple platforms/archs
#
BUILD_PLATFORMS="linux windows darwin freebsd arm64"
BUILD_ARCHS="amd64 386"
# For each platform
for OS in ${BUILD_PLATFORMS[@]}; do
# For each arch
for ARCH in ${BUILD_ARCHS[@]}; do
cd ${D}
# Setup a suffix for the binary
SUFFIX="${OS}"
# i386 is better than 386
if [ "$ARCH" = "386" ]; then
SUFFIX="${SUFFIX}-i386"
else
SUFFIX="${SUFFIX}-${ARCH}"
fi
# Windows binaries should end in .EXE
if [ "$OS" = "windows" ]; then
SUFFIX="${SUFFIX}.exe"
fi
echo "Building for ${OS} [${ARCH}] -> ${BASE}-${SUFFIX}"
# Run the build
export GOARCH=${ARCH}
export GOOS=${OS}
export CGO_ENABLED=0
# hack for ARM
if [ "${GOOS}" = "arm64" ]; then
export GOOS=""
export GOARCH=arm64
export GOARM=7
SUFFIX="arm64"
fi
# Build the main-binary
go build -ldflags "-X main.version=$(git describe --tags 2>/dev/null || echo 'master')" -o "${BASE}-${SUFFIX}"
# Build each bridge
for br in ${D}/bridges/*/; do
bridge=$(basename $br)
# Build the bridge I use
cd ${br}
go build -o ../../${bridge}-${SUFFIX}
done
done
done