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: } andrewm@58: andrewm@58: OPTIND=1 andrewm@58: andrewm@58: while getopts "b:h" opt; do andrewm@58: case $opt in giuliomoro@367: b) BBB_BELA_HOME=$OPTARG andrewm@58: ;; andrewm@58: h|\?) usage andrewm@58: exit 1 andrewm@58: 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@377: read -p "Warning: this script will DELETE any existing Bela files from your BeagleBone! Continue? (y/N) " -r andrewm@58: echo giuliomoro@243: if [[ $REPLY = [yY] ]] andrewm@58: then giuliomoro@377: # Stop Bela if running and remove all files giuliomoro@377: echo "Stopping Bela and removing old files." giuliomoro@377: ssh $BBB_ADDRESS "screen -X -S Bela quit &>/dev/null; pkill Bela; sleep 0.5 ; rm -rf $BBB_BELA_HOME ; mkdir $BBB_BELA_HOME" andrewm@58: andrewm@58: # Copy relevant files to BeagleBone Black andrewm@58: echo "Copying new files to BeagleBone..." l@406: 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@402: scp -q $SCRIPTDIR/../libpd.so $BBB_ADDRESS:/usr/lib giuliomoro@64: if [ $? -ne 0 ] giuliomoro@64: then giuliomoro@64: echo "Error while copying files" giuliomoro@64: exit giuliomoro@64: fi giuliomoro@402: # Create remaining directories needed for building andrewm@58: echo "Creating directory structure on BeagleBone..." giuliomoro@367: 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" &&\ andrewm@58: echo "Done." l@407: echo "Creating on-board documentation..." l@407: ssh $BBB_ADDRESS "cd $BBB_BELA_HOME; doxygen" &&\ l@407: echo "Done." giuliomoro@83: else giuliomoro@83: echo "Aborting..." giuliomoro@402: exit andrewm@58: fi andrewm@58: giuliomoro@402: #------------- giuliomoro@402: #Installing IDE giuliomoro@402: stat $IDE_FOLDER/scripts/setup_IDE.sh > /dev/null giuliomoro@402: if [ $? -eq 0 ] giuliomoro@402: then giuliomoro@402: cd $IDE_FOLDER/scripts; giuliomoro@402: ./setup_IDE.sh giuliomoro@402: else giuliomoro@402: echo "No IDE found, no IDE installed. You can get a copy of the IDE files from https://github.com/LBDonovan/bela-ide" giuliomoro@402: fi;