andrewm@58: #!/bin/bash andrewm@58: # giuliomoro@377: # This script copies the core Bela files to the BeagleBone Black andrewm@58: # in preparation for building projects. It will remove any existing giuliomoro@377: # Bela directory before copying the files over andrewm@58: giuliomoro@367: [ -z "$BBB_ADDRESS" ] && BBB_ADDRESS="root@192.168.7.2" giuliomoro@377: [ -z "$BBB_BELA_HOME" ] && BBB_BELA_HOME="~/Bela/" andrewm@58: function usage andrewm@58: { andrewm@58: THIS_SCRIPT=`basename "$0"` andrewm@58: echo "Usage: $THIS_SCRIPT [-b path-on-beaglebone]" andrewm@58: andrewm@58: echo " giuliomoro@377: This script copies the core Bela files to the BeagleBone, REMOVING andrewm@58: any previous files found at that location. This should be done before andrewm@58: running any of the other build scripts in this directory. The -b option giuliomoro@367: changes the default path, which is otherwise $BBB_BELA_HOME." andrewm@58: } giuliomoro@412: trap "exit" SIGINT SIGTERM giuliomoro@412: giuliomoro@412: function error_handler { giuliomoro@412: [ $1 -eq 0 ] && printf "done\n" || { [ -z "$2" ] && printf "\nAn error occurred. Is the board connected?\n" || printf "$2"; exit 1; } giuliomoro@412: } andrewm@58: andrewm@58: OPTIND=1 giuliomoro@412: ALWAYS_YES=0 giuliomoro@412: while getopts "b:hy" opt; do giuliomoro@412: case $opt in giuliomoro@412: b) BBB_BELA_HOME=$OPTARG giuliomoro@412: ;; giuliomoro@412: h|\?) usage giuliomoro@412: exit 1 giuliomoro@412: ;; giuliomoro@412: y) ALWAYS_YES=1 giuliomoro@412: ;; giuliomoro@412: esac andrewm@58: done andrewm@58: giuliomoro@377: echo "Copying Bela core files to $BBB_BELA_HOME" andrewm@58: andrewm@58: shift $((OPTIND-1)) andrewm@58: andrewm@58: # Find location of this script so we can locate the rest of the files giuliomoro@300: SCRIPTPATH=$(readlink "$0") andrewm@58: SCRIPTDIR=$(dirname "$SCRIPTPATH") l@405: [ -z "$IDE_FOLDER" ] && IDE_FOLDER=$SCRIPTDIR/../../bela-ide/ andrewm@58: giuliomoro@412: if [ $ALWAYS_YES -ne 1 ]; andrewm@58: then giuliomoro@412: printf "Warning: this script will DELETE any existing Bela files from your BeagleBone! Continue? (y/N) " giuliomoro@412: read REPLY; giuliomoro@412: [ $REPLY != y ] && [ $REPLY != Y ] && { echo "Aborting..."; exit 1; } giuliomoro@412: fi; giuliomoro@412: giuliomoro@377: # Stop Bela if running and remove all files giuliomoro@412: printf "Stopping Bela and removing old files..." giuliomoro@412: ssh $BBB_ADDRESS "screen -X -S Bela quit &>/dev/null; pkill Bela; sleep 0.5 ; rm -rf $BBB_BELA_HOME ; mkdir $BBB_BELA_HOME"; giuliomoro@412: error_handler $? andrewm@58: andrewm@58: # Copy relevant files to BeagleBone Black giuliomoro@412: printf "Copying new files to BeagleBone..." giuliomoro@412: scp -q -r $SCRIPTDIR/../core $SCRIPTDIR/../include $SCRIPTDIR/../Makefile $SCRIPTDIR/../libNE10.a $SCRIPTDIR/../libprussdrv.a $SCRIPTDIR/../examples $SCRIPTDIR/../Doxyfile $BBB_ADDRESS:$BBB_BELA_HOME &&\ giuliomoro@412: scp -q $SCRIPTDIR/../libpd.so $BBB_ADDRESS:/usr/lib giuliomoro@412: error_handler $? giuliomoro@412: giuliomoro@402: # Create remaining directories needed for building giuliomoro@412: printf "Creating directory structure on BeagleBone..." giuliomoro@412: ssh $BBB_ADDRESS "mkdir -p $BBB_BELA_HOME/build ; mkdir -p $BBB_BELA_HOME/build/core ; mkdir -p $BBB_BELA_HOME/build/projects; mkdir -p $BBB_BELA_HOME/projects" giuliomoro@412: error_handler $? giuliomoro@412: giuliomoro@412: printf "Creating on-board documentation..." giuliomoro@412: ssh $BBB_ADDRESS "cd $BBB_BELA_HOME; doxygen &>/dev/null" giuliomoro@412: error_handler $? "\nError while generating Doxygen documentation\n" andrewm@58: giuliomoro@402: #------------- giuliomoro@402: #Installing IDE giuliomoro@412: stat $IDE_FOLDER/scripts/setup_IDE.sh &> /dev/null giuliomoro@402: if [ $? -eq 0 ] giuliomoro@402: then giuliomoro@402: cd $IDE_FOLDER/scripts; giuliomoro@412: ./setup_IDE.sh -y giuliomoro@402: else giuliomoro@412: echo "Bela was installed on the board, but No IDE was found, so the IDE was not installed. You can get a copy of the IDE files from https://github.com/LBDonovan/bela-ide" giuliomoro@402: fi;