diff --git a/build.sh b/build.sh index 1eb5fb0..2240d46 100755 --- a/build.sh +++ b/build.sh @@ -1,24 +1,150 @@ #!/bin/bash -echo "Purging old builds" -rm -v bin/* 2>/dev/null -echo "Removing Logs" -rm -v bin/log/* 2>/dev/null +# adding commands +usage() { + # how to use this build script + cat </dev/null + else + read -p "Clean old builds?(y/n) " -n 1 -r + if [[ $REPLY =~ ^[Yy]$ ]] ; then + rm -v bin/* 2>/dev/null + fi + fi + printf 'Clean!\n' +} -echo "Compressing binaries for distrubution" -tar -czf pireactor.tar.gz -C bin reactor_linux_arm64 -tar -czf bbreactor.tar.gz -C bin reactor_linux_arm -tar -czf server.tar.gz -C bin server_linux_amd64 -tar -czf tui.tar.gz -C bin tui_linux_amd64 tui_linux_arm tui_linux_arm64 +create_build() { + # create build for $1 + case $1 in + 'rpi' ) + printf 'Building for Raspberry Pi!\n' + GARCH="arm64" + PLATFORM="reactor" + ;; + 'bb') + printf 'Building for BeagleBone!\n' + GARCH="arm" + GARM="GOARM=7" + PLATFORM="reactor" + ;; + 's') + printf 'Building for BeagleBone!\n' + GARCH="amd64" + PLATFORM="server" + ;; + 'd') + printf 'Building for BeagleBone!\n' + GARCH="amd64" + PLATFORM="server" + ;; + * ) + printf 'ERROR: %s type unrecognized!\n' "$1" + usage + exit 1 + ;; + esac + # setting up build + OUTFILE=$(printf '%s_linux_%s' "$PLATFORM" "$GARCH") + INFILE=$(printf '%s/main.go' "$PLATFORM") + # building + env GOOS=linux GOARCH="$GARCH" $GARM go build -o bin/"$OUTFILE" cmd/"$INFILE" + echo "Finished" + if [[ "$SCP"=true ]] ; then + printf 'Attempting to transfer to %s\n' "$2" + if [[ "$1" == "bb" ]] ; then + printf 'Copying to %s\n' "192.168.100.90" + scp "$HOME/FRMS/bin/$OUTFILE" debian:~/ + else + printf 'SCP Not available!\n' + fi + fi +} + +# handle long form +for arg in "$@"; do + shift + case "$arg" in + '--help') set -- "$@" "-h" ;; + '--list') set -- "$@" "-l" ;; + '--scp') set -- "$@" "-s" ;; + '--clean') set -- "$@" "-c" ;; + '--force') set -- "$@" "-f" ;; + *) set -- "$@" "$arg" ;; + esac +done + +# handle args +while getopts "lcsfh" opt ; do + case "$opt" in + 'h' ) + usage + exit 0 + ;; + 'c' ) + clean_builds + ;; + 'f' ) + FORCE=true + clean_builds + ;; + 's' ) + SCP=true + ;; + 'l') + list_systems + ;; + '?' ) + usage + exit 1 + ;; + esac +done + +shift $(($OPTIND - 1)) + +for dev in "$@"; do + case "$dev" in + 'RaspberryPi') dev='rpi' ;; + 'BeagleBone') dev='bb' ;; + 'Server') dev='s' ;; + 'Desktop') dev='d' ;; + esac + echo "$dev" + create_build "$dev" +done +printf 'Nothing else to do!\n' + +# echo "Compressing binaries for distrubution" +# tar -czf pireactor.tar.gz -C bin reactor_linux_arm64 +# tar -czf bbreactor.tar.gz -C bin reactor_linux_arm +# tar -czf server.tar.gz -C bin server_linux_amd64 +# tar -czf tui.tar.gz -C bin tui_linux_amd64 tui_linux_arm tui_linux_arm64 diff --git a/cmd/reactor/bb_build.sh b/cmd/reactor/bb_build.sh deleted file mode 100755 index f00e803..0000000 --- a/cmd/reactor/bb_build.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -env GOOS=linux GOARCH=arm GOARM=7 go build -o ../../bin/ diff --git a/cmd/server/build.sh b/cmd/server/build.sh deleted file mode 100755 index 4466e6b..0000000 --- a/cmd/server/build.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -go build -race -o ../../bin/server_$GOOS_$GOARCH diff --git a/debian b/debian deleted file mode 100755 index 7f24f2b..0000000 Binary files a/debian and /dev/null differ diff --git a/notes.md b/internal/notes/notes.md similarity index 100% rename from notes.md rename to internal/notes/notes.md diff --git a/old_notes b/internal/notes/old_notes similarity index 100% rename from old_notes rename to internal/notes/old_notes diff --git a/structure b/internal/notes/structure similarity index 100% rename from structure rename to internal/notes/structure