Skip to content

Instantly share code, notes, and snippets.

@carneeki
Last active June 29, 2018 15:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save carneeki/5a5df15fb3ee86508bf6c35c70cdc024 to your computer and use it in GitHub Desktop.
Save carneeki/5a5df15fb3ee86508bf6c35c70cdc024 to your computer and use it in GitHub Desktop.
FUCAN compile scripts
#!/usr/bin/zsh
DESTHOST="fucan.local"
DESTHOME="/home/carneeki"
SRCHOME="/home/carneeki"
BUILDDIR="/tmp/carneeki"
UGS_SRCDIR="$SRCHOME/Sources/ugs"
UGS_BUILDDIR="$BUILDDIR/ugs"
UGS_SRCZIP="$UGS_BUILDDIR/ugs-platform/application/target/ugs-platform-app-2.0-SNAPSHOT.zip"
UGS_DESTZIP="$DESTHOME/ugsplatform.zip"
UGS_DESTDIR="$DESTHOME/ugsplatform"
UGS_DESTSHORTCUT="$DESTHOME/.bin/ugsplatform"
GRBL_SRCDIR="$SRCHOME/Sources/gnea/grbl"
GRBL_BUILDDIR="$BUILDDIR/grbl"
GRBL_DESTDIR="$DESTHOME/Sources/gnea/grbl"
autoload colors
if [[ "$terminfo[colors]" -gt 8 ]]; then
colors
fi
function grbl_pull()
{
print "[" $fg_bold[cyan] "grbl_pull()..." $reset_color "]"
cd $GRBL_SRCDIR
git pull
print "[" $fg_bold[green] "Done!" $reset_color "]"
}
function grbl_prep_build()
{
print "[" $fg_bold[cyan] "grbl_prep_build()..." $reset_color "]"
[ -e "$GRBL_BUILDDIR" ] && rm -rf $GRBL_BUILDDIR
[ ! -e "$BUILDDIR" ] && mkdir $BUILDDIR
mkdir $GRBL_BUILDDIR
cp -pr $GRBL_SRCDIR $GRBL_BUILDDIR/..
print "[" $fg_bold[green] "Done!" $reset_color "]"
}
function grbl_compile()
{
print "[" $fg_bold[cyan] "grbl_compile()..." $reset_color "]"
cd $GRBL_BUILDDIR
make clean
make
print "[" $fg_bold[green] "Done!" $reset_color "]"
}
function grbl_copy()
{
print "[" $fg_bold[cyan] "grbl_copy()..." $reset_color "]"
ssh $DESTHOST "[ -e "$GRBL_DESTDIR" ] && rm -rf $GRBL_DESTDIR"
scp -pr $GRBL_BUILDDIR $DESTHOST:$GRBL_DESTDIR
print "[" $fg_bold[green] "Done!" $reset_color "]"
}
function grbl_upload_hex()
{
print "[" $fg_bold[cyan] "grbl_upload_hex()..." $reset_color "]"
ssh $DESTHOST $DESTHOME/arduino-1.8.5/hardware/tools/avr/bin/avrdude -C $DESTHOME/arduino-1.8.5/hardware/tools/avr/etc/avrdude.conf -v -patmega328p -carduino -P/dev/ttyAMA0 -b115200 -D -Uflash:w:$DESTHOME/Sources/gnea/grbl/grbl.hex:i
print "[" $fg_bold[green] "Done!" $reset_color "]"
}
function grbl_serialise_build()
{
print "[" $fg_bold[cyan] "grbl_serialise_build()..." $reset_color "]"
cp -pr $GRBL_BUILDDIR/* $GRBL_SRCDIR
print "[" $fg_bold[green] "Done!" $reset_color "]"
}
function ugs_pull()
{
print "[" $fg_bold[cyan] "ugs_pull()..." $reset_color "]"
cd $UGS_SRCDIR
git pull
print "[" $fg_bold[green] "Done!" $reset_color "]"
}
function ugs_prep_build ()
{
print "[" $fg_bold[cyan] "ugs_prep_build()..." $reset_color "]"
[ -e "$UGS_BUILDDIR" ] && rm -rf $UGS_BUILDDIR
[ ! -e "$BUILDDIR" ] && mkdir $BUILDDIR
mkdir $UGS_BUILDDIR
cp -pr $UGS_SRCDIR $UGS_BUILDDIR/..
print "[" $fg_bold[green] "Done!" $reset_color "]"
}
function ugs_make_package()
{
print "[" $fg_bold[cyan] "ugs_make_package()..." $reset_color "]"
cd $UGS_BUILDDIR
mvn clean
mvn package
print "[" $fg_bold[green] "Done!" $reset_color "]"
}
function ugs_serialise_build()
{
print "[" $fg_bold[cyan] "ugs_serialise_build()..." $reset_color "]"
cp -pr $UGS_BUILDDIR/* $UGS_SRCDIR
print "[" $fg_bold[green] "Done!" $reset_color "]"
}
function ugs_copy_package()
{
print "[" $fg_bold[cyan] "ugs_copy_package()..." $reset_color "]"
ssh $DESTHOST "[ -e $UGS_DESTDIR ] && rm -rf $UGS_DESTDIR"
ssh $DESTHOST "[ -e $UGS_DESTZIP ] && rm -rf $UGS_DESTZIP"
scp -pr $UGS_SRCZIP $DESTHOST:$UGS_DESTZIP
ssh $DESTHOST rm -rf $UGS_DESTDIR
ssh $DESTHOST unzip -q -o $UGS_DESTZIP
ssh $DESTHOST "[ ! -e $DESTSHORTCUT ] && ln -s $UGS_DESTDIR/bin/ugsplatform $DESTSHORTCUT"
print "[" $fg_bold[green] "Done!" $reset_color "]"
}
function ugs_build()
{
START=$(date +%s)
ugs_prep_build
ugs_make_package
ugs_copy_package
ugs_serialise_build
print "Seconds: $fg_bold[cyan] $(($(date +%s)-$START))" $reset_color
}
function grbl_build()
{
grbl_prep_build
grbl_compile
grbl_copy
grbl_upload_hex
grbl_serialise_build
}
case "$1" in
ugs)
case "$2" in
compile) ugs_make_package ;;
deploy) ugs_copy_package ;;
serialise) ugs_serialise_build ;;
prep) ugs_prep_build ;;
pull) ugs_pull ;;
build)
START=$(date +%s)
ugs_build
print "Seconds: $fg_bold[cyan] $(($(date +%s)-$START))" $reset_color
;;
*)
print "Usage fucan.zsh $1 [compile|deploy|serialise|prep|$fg_bold[red]pull$reset_color|$fg_bold[red]build$reset_color]"
;;
esac
;;
grbl)
case "$2" in
compile) grbl_compile ;;
copy) grbl_copy ;;
deploy)
grbl_copy
grbl_upload_hex
;;
prep) grbl_prep_build ;;
pull) grbl_pull ;;
serialise) grbl_serialise_build ;;
upload) grbl_upload_hex ;;
build)
START=$(date +%s)
grbl_build
print "Seconds: $fg_bold[cyan] $(($(date +%s)-$START))" $reset_color
;;
*)
print "Usage fucan.zsh $1 [compile|copy|deploy|prep|$fg_bold[red]pull$reset_color|serialise|upload|$fg_bold[red]build$reset_color]"
;;
esac
;;
all)
grbl_pull
grbl_build
ugs_pull
ugs_build
;;
*)
print "Usage $0 [all|ugs|grbl]"
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment