forked from prasmussen/gdrive
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-all.sh
executable file
·47 lines (35 loc) · 978 Bytes
/
build-all.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
#!/bin/bash
if [ -z "$1" ]; then
echo "Usage: $0 <app>"
exit 1
fi
# Load crosscompile environment
source /Users/pii/scripts/golang-crosscompile/crosscompile.bash
PLATFORMS="darwin/386 darwin/amd64 freebsd/386 freebsd/amd64 linux/386 linux/amd64 linux/arm linux/rpi windows/386 windows/amd64"
APP_NAME=$1
# Remove old binaries
rm bin/*
# Build binary for each platform in parallel
for PLATFORM in $PLATFORMS; do
GOOS=${PLATFORM%/*}
GOARCH=${PLATFORM#*/}
BIN_NAME="${APP_NAME}-$GOOS-$GOARCH"
if [ $GOOS == "windows" ]; then
BIN_NAME="${BIN_NAME}.exe"
fi
# Raspberrypi seems to need arm5 binaries
if [ $GOARCH == "rpi" ]; then
export GOARM=5
GOARCH="arm"
else
unset GOARM
fi
BUILD_CMD="go-${GOOS}-${GOARCH} build -o bin/${BIN_NAME} $APP_NAME.go"
echo "Building $BIN_NAME"
$BUILD_CMD &
done
# Wait for builds to complete
for job in $(jobs -p); do
wait $job
done
echo "All done"