summaryrefslogtreecommitdiff
path: root/gobuild.sh
diff options
context:
space:
mode:
authorKyle Gunger <kgunger12@gmail.com>2022-07-12 23:33:10 -0400
committerKyle Gunger <kgunger12@gmail.com>2022-07-12 23:33:10 -0400
commit81300fda909b260ff62ae1af9157cf0d097a47c0 (patch)
tree67db1700507525d2d57df25eb1bdbdb9b56ace8d /gobuild.sh
parent60fb718233fc9cac7741f0f9cc41c1b8b2dd2918 (diff)
[BUIL:D] Update build script
Diffstat (limited to 'gobuild.sh')
-rwxr-xr-xgobuild.sh55
1 files changed, 54 insertions, 1 deletions
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] <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