-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathb
48 lines (42 loc) · 1.59 KB
/
b
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 -e
projectname=a1go
cmd_pkg_dir=./cmd/$projectname
echo "$projectname buildscript"
echo
echo " optional args:"
echo " all - build for all platforms."
echo " release - build in the build_release folder (otherwise builds in build_dev) and"
echo " adds the \"release\" build tag."
echo " any other arg - inserted as a build tag."
echo
echo " useful tags: release, profiling_cpu, profiling_mem, profiling_block, profiling_live"
echo
echo "running fmt, vet, etc..."
echo
goimports -w *.go cmd/*/*.go
go vet . ./cmd/*
build_folder="build_dev"
while [ "$#" -ne 0 ]; do
case "$1" in
"all") build_all_platforms=1 ;;
"release") build_folder="build_release" ;& # fallthrough
*) build_tags="$build_tags$1," ;;
esac
shift
done
mkdir -p "$build_folder"
if [ $build_tags ]; then
build_tags="-tags $build_tags"
fi
if [ $build_all_platforms ]; then
set -x
env GOOS=windows GOARCH=amd64 go build $build_tags -o $build_folder/$projectname-win-x64.exe $cmd_pkg_dir
env GOOS=linux GOARCH=amd64 go build $build_tags -o $build_folder/$projectname-linux-x64 $cmd_pkg_dir
env GOOS=darwin GOARCH=amd64 go build $build_tags -o $build_folder/$projectname-mac-x64 $cmd_pkg_dir
env GOOS=linux GOARCH=arm GOARM=6 go build $build_tags -o $build_folder/$projectname-rpi $cmd_pkg_dir
env GOOS=linux GOARCH=arm GOARM=7 go build $build_tags -o $build_folder/$projectname-rpi2 $cmd_pkg_dir
else
set -x
cd $build_folder # to avoid -o option, which requires manually setting a different file extension on windows
go build $build_tags ../$cmd_pkg_dir
fi