From 81300fda909b260ff62ae1af9157cf0d097a47c0 Mon Sep 17 00:00:00 2001 From: Kyle Gunger Date: Tue, 12 Jul 2022 23:33:10 -0400 Subject: [BUIL:D] Update build script --- gobuild.sh | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 54 insertions(+), 1 deletion(-) (limited to 'gobuild.sh') diff --git a/gobuild.sh b/gobuild.sh index e85b718..589f30d 100755 --- a/gobuild.sh +++ b/gobuild.sh @@ -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] " + 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 -- cgit v1.2.3