diff options
| author | Kyle Gunger <kgunger12@gmail.com> | 2022-07-12 23:33:10 -0400 | 
|---|---|---|
| committer | Kyle Gunger <kgunger12@gmail.com> | 2022-07-12 23:33:10 -0400 | 
| commit | 81300fda909b260ff62ae1af9157cf0d097a47c0 (patch) | |
| tree | 67db1700507525d2d57df25eb1bdbdb9b56ace8d | |
| parent | 60fb718233fc9cac7741f0f9cc41c1b8b2dd2918 (diff) | |
[BUIL:D] Update build script
| -rwxr-xr-x | gobuild.sh | 55 | 
1 files changed, 54 insertions, 1 deletions
| @@ -2,7 +2,60 @@  SRCDIR=$(pwd) +# Go options  export GOPATH="$GOPATH:$SRCDIR"  export GO111MODULE="off" -go build -o build/${1} src/${1}.go +# Build windows +win () { +	export GOOS=windows +	go build -o build/${1}.exe src/${1}.go +} + +# Build linux +linux () { +	export GOOS=linux +	go build -o build/${1} src/${1}.go +} + +# Build mac +mac () { +	export GOOS=darwin +	go build -o build/${1} src/${1}.go +} + +# Build all +all () { +	win $1 +	mac $1 +	linux $1 +} + +# Help text +print_help () { +	echo "" +	echo "Usage: gobuild.sh [os] [program] <arch>" +	echo "" +	echo "   os: (mac, linux, win, all)" +	echo " prog: (tint, parse)" +	echo " arch: any supported go arch for the target os" +	echo "" +} + +# Check if given os is valid +is_os () { +	if [[($1 == "mac") || ($1 == "linux") || ($1 == "win") || ($1 == "all")]]; then +		return 0 +	fi +	return 1 +} + +if [[ -n $3 ]]; then +	export GOARCH=$3 +fi + +if $(is_os $1); then +	$1 $2 +else +	print_help +fi |