scripts

My personal collection of scripts
git clone git://src.gearsix.net/scripts
Log | Files | Refs | Atom | README | LICENSE

gobuild.sh (747B)


      1 #!/bin/bash
      2 # DESCRIPTION: build a go pkg for all supported platforms
      3 # DEPENDENCIES: go
      4 
      5 if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
      6 	echo "Usage: gobuild SRC..."
      7 	echo ""
      8 	echo "build a go binary for every platform"
      9 	echo "this will set the GOARCH and GOOS variables and run 'go build'"
     10 	echo "for when you want to build a binary to distribute for as many platforms as possible"
     11 	exit
     12 fi
     13 
     14 name=$1
     15 src=$2
     16 arch=(amd64 386 arm)
     17 os=(linux windows darwin dragonfly openbsd netbsd freebsd)
     18 
     19 for a in ${arch[@]}; do
     20 	for o in ${os[@]}; do
     21 		if [[ $a = "arm" || $a = "386" ]]; then
     22 			if [[ $o = "darwin" || $o = "dragonfly" ]]; then
     23 				continue
     24 			fi
     25 		fi
     26 
     27 		echo "building $name-$a-$o"
     28 		GOARCH=$a GOOS=$o go build -o $name-$a-$o $src
     29 	done
     30 done